ssmtp を使用して Gmail アカウントにメールを送信する方法

ssmtp を使用して Gmail アカウントにメールを送信する方法

次のssmtp.confファイルがあります。

[email protected]
mailhub=smtp.gmail.com:587
hostname=ed424cef9b52
UseTLS=Yes
UseStartTTLS=Yes
AuthMethod=LOGIN
AuthUser=test
AuthPass=test
FromLineOverride=yes
TLS_CA_File=/etc/ssl/certs/ca-certificates.crt

587 Gmail ポートに接続できます。

telnet smtp.gmail.com 587
Trying 64.233.186.109...
Connected to gmail-smtp-msa.l.google.com.

しかし、メールを送信しようとすると:

/usr/sbin/ssmtp -v [email protected] < qq
ssmtp: Cannot open smtp.gmail.com:587

echo test | mailx  -s "testing ssmtp setup" [email protected]
send-mail: Cannot open smtp.gmail.com:587
Can't send mail: sendmail process failed with error code 1

ベストアンサー1

正しいポートは465です。

Gmailを使用してコマンドラインから画像添付ファイルを含むメールを送信する最も簡単な方法は何ですか?


抜粋:

次のコマンドを使用してssmtpをインストールします。

sudo apt-get update
sudo apt-get install ssmtp

次に、/etc/ssmtpに移動し、ssmtp.confを次のように編集します。

[email protected]
mailhub=smtp.gmail.com:465
FromLineOverride=YES
[email protected]
AuthPass=testing123
UseTLS=YES

次の行を送信します。

echo "Testing...1...2...3" | ssmtp [email protected]

次のように書式設定されたテキストファイルを送信します。

cat mymessage | ssmtp [email protected]

ここで、mymessage は TO: および SUBJECT: 行とテキストを含むように書式設定できます。

TO: [email protected]
SUBJECT: Testing
     -blank line-
Message body goes here....

おすすめ記事