Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
202 views
in Technique[技术] by (71.8m points)

linux - How to send email using ssmtp

I am attempting to write a script which send emails containing log messages...

Firstly, I have installed ssmtp and configured /etc/ssmtp/ssmtp.conf as follows:

#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
[email protected]

# 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
[email protected]
AuthPass=mypassword
AuthMethod=LOGIN

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

Then I tried to send me a test mail

user@ananas:~$ echo -e 'Subject: test

Testing ssmtp' | sendmail -v [email protected]
[<-] 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)

I haven't received any mail. What am I doing wrong?

question from:https://stackoverflow.com/questions/65861238/how-to-send-email-using-ssmtp

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

ssmtp is nearly to be no longer supported. I tried to use the suggested package msmtp, and it works


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...