2013-05-09 12 views
6

私は特定の状況下で電子メールを送信するcronタスクによって実行されるbashスクリプトを作成しようとしています。コマンドラインからsendmailを使用する

試してみて、私のSendgrid SMTP設定で作業sendmailを得るために、私は次のと /etc/postfix/main.cfファイル編集した:私はを使用してのpostfixを再起動

smtp_sasl_password_maps = static:<username>:<password> 
smtp_sasl_security_options = noanonymous 
smtp_tls_security_level = may 
smtp_tls_security_level=encrypt 
header_size_limit = 4096000 
relayhost = [smtp.sendgrid.net]:587 

をsudoの/etc/init.d/postfix再起動

、次のコマンドを使用して、コマンドラインからメールを送信しようとした:

sendmailの[email protected] < /tmp/email.txtこれは、次のような出力になり

あなたがの/ var /メールで新しいメールを持っている/ Ubuntuの

なぜmain.cfで指定したSendgrid SMTPの詳細を使って私の電子メールでsendgridを送信していませんか?

この質問はsendmailのみに関するものであり、私は他のSMTPクライアントやアプリケーションをインストールしたくないということに注意してください。

答えて

10

私のPostfix設定が間違っていました。次のように行われている

smtp_sasl_auth_enable = yes 
smtp_sasl_password_maps = static:<username>:<password> 
smtp_sasl_security_options = noanonymous 
smtp_tls_security_level = may 
header_size_limit = 4096000 
relayhost = [smtp.sendgrid.net]:587 

bashスクリプトを経由してメールを送信:私は次のように使用するのに必要な

sendmail [email protected] <<EOF 
subject:This is a test 
from:[email protected] 
Body message here... 
EOF 
関連する問題