0

I am trying to install Postfix on a server and have it go through a relay. I would like to have the email with a custom domain, so I bought a domain and registered a A record to point to the relayHost's IP. Note: I am hosting all the servers (VPS’s) on Cloudzy. Here is the steps I do and configurations I have for it:

On server A, I do

apt-get install postfix

and

apt-get install mailutils

followed by

service postfix restart

On server B, I do the exact same commands.

On server A and B, I choose the exact same choices

Local only
System mail name is bought domain name: *******.com
Root and postmaster recipient are the same: *linuxuser*
Destinations to accept mail are both:  localhost.com, localhost, *******.com
Force synchronous mail: No
Local networks: 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
Mailbox size limit: 0
Local address extension character: +
Internet protocols to use: all

Now, I go to edit the /etc/postfix/main.cf file on server B and make these changes

myhostname = *******.com #bought domain name
mynetworks = <Server A IP address> 127.0.0.0./8
inet_interfaces = all
smtp_enforce_tls = yes
smtp_tls_security_level = encrypt

On server A, I make these changes to the main.cf file aswell

relayhost = <Server B IP address>
smtp_enforce_tls = yes
smtp_tls_security_level = encrypt

Side by side comparison of /etc/postfix/main.cf files on both servers

Server A

...
smtp_tls_CApath=/etc/ssl/certs
smtp_tls_security_level = encrypt
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtp_enforce_tls = yes

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = *******.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = localhost.com, localhost, *******.com
relayhost = <Server B address>
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
default_transport = error
relay_transport = error
inet_protocols = all

Server B

...
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_security_level=may

smtp_tls_CApath=/etc/ssl/certs
smtp_tls_security_level = encrypt
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtp_enforce_tls = yes

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = *******.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = localhost.com, localhost, *******.com
relayhost =
mynetworks = <Server A IP Address> 127.0.0.0/8
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
default_transport = error
relay_transport = error
inet_protocols = all

And restart the service on both servers.

I go to send a test email by doing echo "This is the body of the email" \ | mail -s "This is the subject line" <email address I want it sent to>

However, the email never ever sends. Please help! I am on Ubuntu 20.04

4
  • Where is the postfix server being hosted? Amazon, DigitalOcean, and a number of other virtual service providers actively block outgoing mail traffic due to all the spammers/scammers. If you're using Amazon, you can open a ticket to have them review your use case and (potentially) open the port for you. A lot of other VPS providers have a zero tolerance policy on this, though.
    – matigo
    Commented Nov 22, 2022 at 7:43
  • @matigo it’s being hosted on Cloudzy! Commented Nov 22, 2022 at 9:15
  • I've not worked with that company. You may want to confirm that the necessary ports are open for use. These would be blocked on the network layer from the VPS provider, so it's not something you can change on your own.
    – matigo
    Commented Nov 22, 2022 at 11:33
  • @matigo thank you! What ports need to be open again? I just want to make sure I have them right! Commented Nov 22, 2022 at 18:02

0

You must log in to answer this question.

Browse other questions tagged .