Я предпринял эти шаги(собрано из многочисленных сообщений на этом форуме и других)для установки и настройки SendMail на моем сервере DigitalOcean, работающем под управлением Ubuntu 18.04.3 (LTS) x64, но мне не удалось заставить его работать.
1. установлен sendmail:
sudo apt-get install sendmail
2. изменено имя хоста:
# sudo hostnamectl set-hostname coffee
# sudo nano /etc/hostname
coffee
# hostname
coffee
3. изменен файл hosts:
# sudo nano /etc/hosts
127.0.0.1 localhost.localdomain localhost
127.0.1.1 coffee.barismo.com coffee
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
4. изменен файл локальных имен хостов:
# sudo nano /etc/mail/local-host-names
localhost
coffee
5. Создана таблица обобщений:
sudo nano /etc/mail/genericstable
www-data [email protected]
root [email protected]
6. Создан файл общих доменов:
sudo nano /etc/mail/generics-domains
barismo.com
7. добавил следующее в sendmail.mc:
sudo nano /etc/mail/sendmail.mc
FEATURE(`genericstable',`hash -o /etc/mail/genericstable.db')dnl
GENERICS_DOMAIN_FILE(`/etc/mail/generics-domains')dnl
8. и наконец перенастроил sendmail и перезапустил службы и сервер:
sudo sendmailconfig
sudo systemctl restart sendmail
sudo service apache2 restart
sudo systemctl restart apache2
After all this, it still doesn't work.
When I tried to send a test email:
# echo "Subject: test" | /usr/lib/sendmail -v [email protected]
I get this error in mail.log:
Jan 19 08:13:07 barismo sm-mta[25919]: 00J837P9025919: to=<[email protected]>,
ctladdr=<[email protected]> (0/0), delay=00:10:00, xdelay=00:10:00,
mailer=esmtp, pri=30295, relay=alt4.gmail-smtp-in.l.google.com. [172.253.112.27],
dsn=4.0.0, stat=Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.
And when I tried to send a mail to myself in my PHP script, I get this error:
Jan 19 08:10:43 barismo sm-mta[26115]: 00J81emc025911: to=<[email protected]>,
ctladdr=<[email protected]> (33/33), delay=00:09:03, xdelay=00:04:22,
mailer=esmtp, pri=210494, relay=shared18.accountservergroup.com. [192.185.134.44],
dsn=4.0.0, stat=Deferred: Connection timed out with shared18.accountservergroup.com.
In case it's relevant, it should be noted that my domain DNS is hosted with Site5 and I have altered only the 'A' record to point to my Digital Ocean droplet, while maintaining the 'MX' records with Site5 to handle mails.
I am still able to send and receive mails from my Site5 mailbox, and the domain name itself (barismo.com & www.barismo.com) resolves correctly to my Digital Ocean droplet without issue.
Any direction will be greatly appreciated. Thank you.
решение1
DigitalOcean seems to block outgoing mail connections by default.
Quote from a DigitalOcean Community Manager on SO:
In order to curb spam and abuse, some new user accounts at DigitalOcean have their SMTP ports blocked by default. Unfortunately there are sometimes false positives. It sounds like this might have been the case for you. If you open a support ticket, the team would be happy to remove that block for you.
So, you need to open a support ticket.