我想通过Ubuntu 14.04版本发送邮件到我的Gmail邮箱ID。 Ubuntu在我的Windows机器上通过VMware运行。 请让我知道,如果上述说明不清楚,因为我是新手在使用虚拟机。 我已经安装了VMware Workstation 12 Player。 然后下载了ubuntu-14.04.4-desktop-amd64.iso并为它创build了一个虚拟机。
我试图运行下面的命令: echo "This is the body of the email" | mail -s "This is the subject line" myemailID echo "This is the body of the email" | mail -s "This is the subject line" myemailID
没有错误提示。 我已经在Ubuntu上执行了以下工具:
sudo apt-get install mailutils sudo apt-get install postfix mailutils libsasl2-2 ca-certificates libsasl2-modules sudo dpkg-reconfigure postfix
我select“Internet站点”作为默认邮件configuration和rest设置。 我通过执行'tail -f /var/log/mail.log'来检查mail.log文件,以下是消息:
Mar 22 16:34:00 ubuntu postfix/qmgr[2743]: 257891057F0: from=<>, size=474, nrcpt=1 (queue active) Mar 22 16:34:00 ubuntu postfix/smtp[2755]: connect to smtp.gmail.com[74.125.70.109]:587: Connection refused Mar 22 16:34:00 ubuntu postfix/smtp[2755]: connect to smtp.gmail.com[74.125.70.108]:587: Connection refused Mar 22 16:34:00 ubuntu postfix/smtp[2755]: 257891057F0: to=<myemailid>, relay=none, delay=0.07, delays=0/0/0.06/0, dsn=4.4.1, status=deferred (connect to smtp.gmail.com[74.125.70.108]:587: Connection refused) Mar 22 16:34:00 ubuntu postfix/pickup[2744]: 3DE6F10580A: uid=1000 from=<> Mar 22 16:34:00 ubuntu postfix/cleanup[2753]: 3DE6F10580A: message-id=<20160322110400.3DE6F10580A@ubuntu> Mar 22 16:34:00 ubuntu postfix/qmgr[2743]: 3DE6F10580A: from=<>, size=476, nrcpt=1 (queue active) Mar 22 16:34:00 ubuntu postfix/smtp[2755]: connect to smtp.gmail.com[74.125.70.108]:587: Connection refused Mar 22 16:34:00 ubuntu postfix/smtp[2755]: connect to smtp.gmail.com[74.125.70.109]:587: Connection refused Mar 22 16:34:00 ubuntu postfix/smtp[2755]: 3DE6F10580A: to=<myemailid>, relay=none, delay=0.05, delays=0/0/0.05/0, dsn=4.4.1, status=deferred (connect to smtp.gmail.com[74.125.70.109]:587: Connection refused)
请引导,让我知道是否需要任何其他信息。
下面还提到/etc/postfix/main.cf文件供参考。
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu) biff = no append_dot_mydomain = no readme_directory = no smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key smtpd_use_tls=yes smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination myhostname = ubuntu alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases mydestination = ubuntu, localhost.localdomain, localhost 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 smtp_tls_policy_maps = hash:/etc/postfix/tls_policy mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = all inet_protocols = ipv4 mynetworks = 127.0.0.0/8 mailbox_command = procmail -a "$EXTENSION"
我模拟了防火墙问题
# host smtp.gmail.com smtp.gmail.com is an alias for gmail-smtp-msa.l.google.com. gmail-smtp-msa.l.google.com has address 74.125.136.109 gmail-smtp-msa.l.google.com has address 74.125.136.108 gmail-smtp-msa.l.google.com has IPv6 address 2a00:1450:4013:c01::6d # iptables -I OUTPUT -d 74.125.136.108 -j DROP # iptables -I OUTPUT -d 74.125.136.109 -j DROP
检查连接
# openssl s_client -connect smtp.gmail.com:587 -starttls smtp socket: Network is unreachable connect:errno=101
这些线意味着你networking上的某个人在端口587阻止连接到smtp.gmail.com。你可以尝试另一个smtp服务器:smtp-mail.outlook.com:25,smtp.mail.yahoo.com:587,smtp。 mail.ru:2525
# openssl s_client -connect smtp.mail.yahoo.com:587 -starttls smtp CONNECTED(00000003) depth=3 C = US, O = "VeriSign, Inc.", OU = Class 3 Public Primary Certification Authority verify return:1 depth=2 C = US, O = "VeriSign, Inc.", OU = VeriSign Trust Network, OU = "(c) 2006 VeriSign, Inc. - For authorized use only", CN = VeriSign Class 3 Public Primary Certification Authority - G5 verify return:1 depth=1 C = US, O = Symantec Corporation, OU = Symantec Trust Network, CN = Symantec Class 3 Secure Server CA - G4 verify return:1 depth=0 C = US, ST = California, L = Sunnyvale, O = Yahoo Inc., OU = Information Technology, CN = smtp.mail.yahoo.com verify return:1 ... --- 250 STARTTLS quit 221 2.0.0 Bye closed
顺便说一句,你有没有试过端口465?
# openssl s_client -connect smtp.gmail.com:465