簡體   English   中英

如何使用 ssmtp 發送 email

[英]How to send email using 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=myname@gmail.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=smtp.gmail.com:587

# The address where the mail appears to come from for user authentication.
rewriteDomain=gmail.com

# The full hostname.  Must be correctly formed, fully qualified domain name or GMail will reject connection.
hostname=ananas

# Use SSL/TLS before starting negotiation
TLS_CA_FILE=/etc/ssl/certs/ca-certificates.crt
UseTLS=Yes
UseSTARTTLS=Yes

# Username/Password
AuthUser=myname@gmail.com
AuthPass=mypassword
AuthMethod=LOGIN

# Email 'From header's can override the default domain?
FromLineOverride=yes

然后我嘗試給我發一封測試郵件

user@ananas:~$ echo -e 'Subject: test\n\nTesting ssmtp' | sendmail -v myname@gmail.com
[<-] 220 smtp.gmail.com ESMTP v20sm16357528wra.19 - gsmtp
[->] EHLO ananas
[<-] 250 SMTPUTF8
[->] STARTTLS
[<-] 220 2.0.0 Ready to start TLS
[->] EHLO ananas
[<-]
sendmail:  (ananas)

我沒有收到任何郵件。 我究竟做錯了什么?

ssmtp幾乎不再受支持。 我嘗試使用建議的 package msmtp ,它可以工作

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM