Я пытаюсь отправить почту через версию Ubuntu 14.04 на свой идентификатор gmail. Ubuntu работает через VMware на моем компьютере с Windows. Пожалуйста, дайте мне знать, если приведенное выше описание непонятно, поскольку я новичок в работе с виртуальной машиной. Сначала я установил VMware Workstation 12 Player. Затем загрузил ubuntu-14.04.4-desktop-amd64.iso и создал для него виртуальную машину.
Я пытаюсь запустить следующую команду: 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
Я выбрал «Интернет-сайт» в качестве конфигурации почты, а остальные настройки по умолчанию. Я проверил файл mail.log, выполнив «tail -f /var/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
эти строки означают, что кто-то в вашей сети блокирует соединение с smtp.gmail.com через порт 587. Вы можете попробовать другой сервер 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
P.S. кстати, а порт 465 пробовали?
# openssl s_client -connect smtp.gmail.com:465