Score:0

I have setup Postfix to send mail with SMTP.Gmail.com server, mail only gets send at server reboot?

fj flag

I am a linux beginner so might be doing something stupid,

My problem,

I am setting up a Ubuntu server LTS 22.04.2, and to get emails when there are updates I am trying to get mail and postfix to work.

I have a very weird problem, I have followed a guide to set up postfix with my gmail account to send with the google smtp server, when I test this with

echo "Test email" | mail -s "Test subject" email adres

it seems to send ok, output is exited with 0 witch is a success (but not getting mail) if I than check the que with this command

mailq

than I see the mail in the que with : (connect to smtp.gmail.com[0.0.0.0]:587: Connection refused) (I dont know why that is saying 0.0.0.0 as adres ??)

But the REAL kicker is, I I than simply reboot my server with "reboot" one's the server is started, I actualy receive the mail !!!!!!! (even multiple mails if I had more than one in the que)

I am using UFW firewall , but even when disabled I have the same problem.

simply stopping and starting the postfix does NOT work, restarting the postfix service does also NOT work, only thing that works is fully rebooting the server.

Edit : some extra log information ; mail.log when I try to send a mail that stay's stuck in the que;

Jun 6 16:07:52 theboyz postfix/smtp[5425]: D14805E8FF6: [email protected], relay=none, delay=5.2, delays=5.2/0.02/0/0, dsn=4.4.1, status=deferred (connect to smtp.gmail.com[0.0.0.0]:587: > Jun 6 16:07:53 theboyz postfix/postfix-script[5474]: refreshing the Postfix mail system Jun 6 16:07:53 theboyz postfix/master[2082]: reload -- version 3.6.4, configuration /etc/postfix

Mail log after I reboot the server and the mail is send;

Jun 6 18:30:56 theboyz postfix/master[1855]: reload -- version 3.6.4, configuration /etc/postfix Jun 6 18:30:56 theboyz postfix/smtp[2474]: D14805E8FF6: [email protected], relay=smtp.gmail.com[173.194.69.109]:587, delay=8590, delays=8587/0.12/1.5/0.76, dsn=2.0.0, status=sent (250 2.0.0 OK 168> Jun 6 18:30:57 theboyz postfix/postfix-script[3298]: refreshing the Postfix mail system Jun 6 18:30:57 theboyz postfix/master[1855]: reload -- version 3.6.4, configuration /etc/postfix Jun 6 18:30:57 theboyz postfix/qmgr[3304]: D14805E8FF6: from=root@theboyz, size=324, nrcpt=1 (queue active) Jun 6 18:30:57 theboyz postfix/qmgr[3304]: D14805E8FF6: removed Jun 6 18:30:57 theboyz postfix/postfix-script[3375]: refreshing the Postfix mail system Jun 6 18:30:57 theboyz postfix/master[1855]: reload -- version 3.6.4, configuration /etc/postfix

Only difference I see is that the SMTP server has an IP of 0.0.0.0 when it fails, and in the logs when I reboot it gets an IP ? so I gues "something" is still starting that screws this up, but my firewall is even disabled for the moment.

extra edit , when I telnet the google smtp server I also get the weird 0.0.0.0 IP ??

telnet smtp.gmail.com 587 Trying 0.0.0.0... Trying ::... telnet: Unable to connect to remote host: Connection refused root@theboyz:~#

I have been reading up on it and I find site's suggesting its a problem with sending IPV6 but the server only understanding IPV4 ?? but still no clue why it works during reboot ??

Can anyone maybey point me in the correct direction ?

Thank you in advance,

Hans

ec flag
**Welcome to the Ask Ubuntu community.** So it will be easier to diagnose your issue, please edit your question to include the version of the Ubuntu OS that you're running.
Hansie avatar
fj flag
Ah , sorry , I will add it, its Ubuntu Server LTS 22.04.2
Hansie avatar
fj flag
extra small question for you, how can I get an email when someone answers here ?? the instructions on stack exchange say I should see a "follow" option under my post , but it only has "share", "edit", "delete" and "flag" ?? I am probably doing something wrong, but I dit not get an email telling me you answered my question.
ec flag
not sure why you don't see the `follow` option, but details here: https://meta.stackexchange.com/questions/345661/the-follow-questions-and-answers-feature-is-now-live-across-the-network
Score:0
fj flag

Ok, problem fixed.

I am an idiote (I dit say that from the start tho :) )

I just checked my adguard home I have running in docker on the server and it had like 6000+ blocked requests for smtp.gmail.com /facepalm

I put the gmail adres on the exception list and it all works fine now,

Gues it send the mail before the docker and adguard home became active during bootup

still one weird thing tho, I have my ubuntu server set up to use the 8.8.8.8 DNS server and NOT my own adguard home specificaly to NOT have this problem, so its weird its still using adguard home's DNS server ???

oh well, sorry to bother you all, problem solved :)

thanks for the help.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.