ターミナルからメールを送信する
Category : Linux
SSMTPをインストール
sudo apt install ssmtp
SSMTPの設定
次に/etc/ssmtp/ssmtp.confの設定を行います。
## Config file for sSMTP sendmail## The person who gets all mail for userids < 1000# Make this empty to disable rewriting.#root=postmasterroot=myemail@hoge.com# The place where the mail goes. The actual machine name is required no# MX records are consulted. Commonly mailhosts are named mail.domain.com#mailhub=mailmailhub=smtp.hoge.com:587AuthUser=myemail@hoge.comAuthPass=*****UseTLS=YESUseSTARTTLS=YES# Where will the mail seem to come from?#rewriteDomain=rewriteDomain=hoge.com# The full hostname#hostname=hostname=MyServer# Are users allowed to set their own From: address?# YES - Allow the user to specify their own From: address# NO - Use the system generated From: addressFromLineOverride=YES
送信テスト
テスト用のメールを作成します。
$ vim testmail.txttestmail.txtTo: recieve@hoge.comFrom: myemail@hoge.comSubject: ssmtp testTest message.
作成したテストメールを送信します。
$ sendmail -t < testmail.txtもしくは$ ssmtp recieve@hoge.com < testmail.txt
送信先に指定したメールアドレスに作成したメッセージが届いていれば成功です。