I have taken these steps (gathered from numerous posts in this forum and others) to install and configure SendMail on my DigitalOcean droplet, running Ubuntu 18.04.3 (LTS) x64, but I have been unable to get it to work.
1. installed sendmail:
sudo apt-get install sendmail
2. changed the host name:
# sudo hostnamectl set-hostname coffee # sudo nano /etc/hostname coffee # hostname coffee
3. amended the hosts file:
# 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. amended the local host names file:
# sudo nano /etc/mail/local-host-names localhost coffee
5. created a generics table:
sudo nano /etc/mail/genericstable www-data email@example.com root firstname.lastname@example.org
6. created a generics domains file:
sudo nano /etc/mail/generics-domains barismo.com
7. added the following to 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. and finally reconfigured sendmail and restarted the services and the server:
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@example.com
I get this error in mail.log:
Jan 19 08:13:07 barismo sm-mta: 00J837P9025919: to=<firstname.lastname@example.org>, ctladdr=<email@example.com> (0/0), delay=00:10:00, xdelay=00:10:00, mailer=esmtp, pri=30295, relay=alt4.gmail-smtp-in.l.google.com. [22.214.171.124], 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: 00J81emc025911: to=<firstname.lastname@example.org>, ctladdr=<email@example.com> (33/33), delay=00:09:03, xdelay=00:04:22, mailer=esmtp, pri=210494, relay=shared18.accountservergroup.com. [126.96.36.199], 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.