POSTFIX:必须首先发出一个STARTTLS命令。 电子邮件不被发送从命令行Ubuntu的

我想从我的Ubuntu服务器的命令行发送电子邮件。 所以我开始configurationpostfix到我的本地机器而不是在服务器上。 所以基本上这些是我遵循的步骤:

sudo apt-get install postfix mailutils libsasl2-2 ca-certificates libsasl2-modules 

sudo vim /etc/postfix/main.cf

将以下行添加到文件中:

 relayhost = [smtp.gmail.com]:587 smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_security_options = noanonymous smtp_tls_CAfile = /etc/postfix/cacert.pem smtp_use_tls = yes 

sudo vim /etc/postfix/sasl_passwd

在文件[smtp.gmail.com]:587 [email protected]:PASSWORD添加了这一行

权限和更新后缀configuration文件。

 sudo chmod 400 /etc/postfix/sasl_passwd sudo postmap /etc/postfix/sasl_passwd 

重新加载POSTFIX: sudo /etc/init.d/postfix reload

然后在我的terminal上运行这个命令:

echo "Test mail from postfix" | mail -s "Test Postfix" [email protected]

但没有收到邮件。 所以我检查了日志文件,这是我发现它的下面的堆栈跟踪:

 postfix/pickup[26530]: A62AF2E29B4: uid=1000 from=<z@mylaptop> postfix/cleanup[27372]: A62AF2E29B4: message-id=<20160428114754.A62AF2E29B4@mylaptop> postfix/qmgr[26529]: A62AF2E29B4: from=<z@mylaptop>, size=365, nrcpt=1 (queue active) postfix/smtp[27379]: cannot load Certificate Authority data: disabling TLS support postfix/smtp[27379]: warning: TLS library problem: error:02001002:system library:fopen:No such file or directory:bss_file.c:169:fopen('/etc/postfix/cacert.pem','r'): postfix/smtp[27379]: warning: TLS library problem: error:2006D080:BIO routines:BIO_new_file:no such file:bss_file.c:172: postfix/smtp[27379]: warning: TLS library problem: error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib:by_file.c:274: postfix/smtp[27379]: connect to smtp.gmail.com[2404:6800:4003:c02::6d]:587: Network is unreachable postfix/smtp[27379]: A62AF2E29B4: to=<[email protected]>, relay=smtp.gmail.com[74.125.68.108]:587, delay=1.4, delays=0.01/0.02/1/0.34, dsn=5.7.0, status=bounced (host smtp.gmail.com[74.125.68.108] said: 530 5.7.0 Must issue a STARTTLS command first. g70sm14489231pfb.7 - gsmtp (in reply to MAIL FROM command)) postfix/cleanup[27372]: 5BFDF2E2B48: message-id=<20160428114756.5BFDF2E2B48@mylaptop> postfix/bounce[27383]: A62AF2E29B4: sender non-delivery notification: 5BFDF2E2B48 postfix/qmgr[26529]: 5BFDF2E2B48: from=<>, size=2239, nrcpt=1 (queue active) postfix/qmgr[26529]: A62AF2E29B4: removed postfix/local[27384]: 5BFDF2E2B48: to=<z@mylaptop>, relay=local, delay=0.01, delays=0/0.01/0/0, dsn=2.0.0, status=sent (delivered to mailbox) postfix/qmgr[26529]: 5BFDF2E2B48: removed 

 postfix/smtp[27379]: cannot load Certificate Authority data: disabling TLS support postfix/smtp[27379]: warning: TLS library problem: error:02001002:system library:fopen:No such file or directory:bss_file.c:169:fopen('/etc/postfix/cacert.pem','r'): 

安装证书颁发机构的证书 – 他们certificate其他证书=>在Debian / Ubuntu上安装名为ca-certificates的软件包。

相关问题: https : //serverfault.com/a/497897/163277