4

I've been trying to get postfix setup so that it can SEND (don't need it to receive) emails out to users on my website (such as account validation emails).

I install postfix through mailutils (installs postfix along with other stuff).

sudo apt-get install mailutils

I then edit the config file for postfix...

sudo nano /etc/postfix/main.cf

I change the line...

inet_interfaces = all

to...

inet_interfaces = localhost

I then restart postfix using this command...

sudo service postfix restart

Finally I test the installation by running the following commands...

php -a
echo mail("myemail@gmail.com", "Hello", "My email worked!");

The echo prints 1 onto the terminal, which should mean the email was sent successfully.... but I've checked my inbox/junk/spam/trash and the email was not received. I've tried with different emails too.

Dennis B.
  • 1,567
  • 1
  • 13
  • 20
Ricky
  • 343
  • 1
  • 2
  • 11

5 Answers5

4

to check your postfix server status look at the log file for problem

 tail -f /var/log/mail.log

you may see somethings like that :

Jun 25 23:53:43 ubuntu postfix/smtp[6576]: connect to gmail-smtp-in.l.google.com[2a00:1450:400c:c06::1b]:25: Network is unreachable

or perhaps this problem:

Jun 25 23:12:41 ubuntu postfix[5152]: Postfix is running with backwards- 
compatible default settings
Jun 25 23:12:41 ubuntu postfix[5152]: See 
http://www.postfix.org/COMPATIBILITY_README.html for details
Jun 25 23:12:41 ubuntu postfix[5152]: To disable backwards compatibility use 
"postconf compatibility_level=2" and "postfix reload"
Jun 25 23:12:42 ubuntu postfix/master[5197]: daemon started -- version 
3.1.0, configuration /etc/postfix

then its better to check out this URL:

https://de.postfix.org/httpmirror/COMPATIBILITY_README.html
3

After what feels like HOURS...

I found out the issue was because I had ipv6 enabled on postfix. I disabled it and that fixed the problem.

Ricky
  • 343
  • 1
  • 2
  • 11
2

To add onto to the OP's own answer and for any new visitors, here are the steps to disable ipv6 and just allow ipv4 which is also what fixed my bouncing issue.

Step 1:

sudo vim /etc/postfix/main.cf

Step 2:

Change inet_protocols= all to inet_protocols= ipv4

Step 3:

sudo systemctl restart postfix

After doing these fixes, my mail was no longer being bounced by gmail and now was just being filtered to spam - a big improvement.

Just as a note - I knew the emails were being bounced because I was watching the postfix logs by executing:

tail -f /var/log/mail.log
Shaan K
  • 356
  • 1
  • 7
0

For me azure vm blocking port 25 so instead of that try to depend on your smtp and port 587 , here my zoho smtp

relayhost = [smtppro.zoho.com]:587
Abdullah Tahan
  • 1,963
  • 17
  • 28
0

I just ran into a problem with this in the config file:

default_transport = error
relay_transport = error

No idea where they came from but I noticed they weren't present in the config file on another server. Commenting them out fixed the problem and allowed email to go out.