LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-11-2024, 06:39 AM   #1
banderas20
Member
 
Registered: Aug 2018
Posts: 138

Rep: Reputation: Disabled
Question Local POSTFIX cannot send to Gmail


Hi.

I have set up a POSTFIX server in an AWS EC2 instance. If I try to send emails between local users using Sendmail, it works.

However, if I try with an external account (gmail for example), it doesn't work.

Command:

Code:
echo "test email" | sendmail account@gmail.com
POSTFIX Log:

Code:
postfix/smtp[2108]: CD4FE4652F: to=<account@gmail.com>, relay=none, delay=150, delays=0.02/0.02/150/0, dsn=4.4.1, status=deferred (connect to alt4.gmail-smtp-in.l.google.com[142.250.153.26]:25: Connection timed out)

from=<ubuntu@srv.ec2.internal
Telnet output:
Code:
telnet gmail-smtp-in.l.google.com 25
Trying 172.253.63.27...
Finally, here is my main.cf file:

Code:
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = abdsrvr.ec2.internal
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = $myhostname, srvr, localhost.localdomain, , localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
#inet_protocols = all
inet_protocols = ipv4
I have port 25 open in the AWS SG.

My guess is that it has something to do with the domain, since my machine is bound to a local domain (ec2.internal), without any DNS record. Maybe GMAIL and other public SMTP servers reject this kind of connections. Anyway, I'd appreciate some help on this.

Thanks!
 
Old 04-12-2024, 05:17 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
AWS by default only allows a handful of direct outbound e-mails per day from an ec2 instance. You need to send through their SES service - https://aws.amazon.com/ses/

Edit: From memory I think you used to be able to request unlimited outbound, but that may have been a while ago.

You may find this useful: https://docs.aws.amazon.com/AWSEC2/l...rt-25-throttle

Last edited by TenTenths; 04-12-2024 at 05:22 AM.
 
Old 04-16-2024, 04:09 AM   #3
banderas20
Member
 
Registered: Aug 2018
Posts: 138

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TenTenths View Post
AWS by default only allows a handful of direct outbound e-mails per day from an ec2 instance. You need to send through their SES service - https://aws.amazon.com/ses/

Edit: From memory I think you used to be able to request unlimited outbound, but that may have been a while ago.

You may find this useful: https://docs.aws.amazon.com/AWSEC2/l...rt-25-throttle
Hi mate.

I'll give it a try. Thanks for the advice!
 
Old 04-20-2024, 06:28 PM   #4
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
this is definitely an AWS issue. if the documentation there does not resolve the issue, talk with AWS support. they may want to be sure your mail server never relays email. what have you done toe sure of that?
 
Old 04-23-2024, 01:47 AM   #5
banderas20
Member
 
Registered: Aug 2018
Posts: 138

Original Poster
Rep: Reputation: Disabled
Hi.

I have tried the same in a VirtualBox VM:

Command

Code:
echo "Test Mail" | sendmail account@gmail.com
POSTFIX log:
Code:
abr 23 08:34:10 MASTER postfix/pickup[1782]: 07AF3121F3A: uid=1000 from=<itb>
abr 23 08:34:10 MASTER postfix/cleanup[2959]: 07AF3121F3A: message-id=<20240423063410.07AF3121F3A@MASTER.domain.here>
abr 23 08:34:10 MASTER postfix/qmgr[1783]: 07AF3121F3A: from=<account@MASTER.domain.here>, size=282, nrcpt=1 (queue active)
abr 23 08:39:10 MASTER postfix/smtp[2961]: 07AF3121F3A: conversation with gmail-smtp-in.l.google.com[173.194.76.27] timed out while receiving the initial server greeting
abr 23 08:39:10 MASTER postfix/smtp[2961]: connect to gmail-smtp-in.l.google.com[2a00:1450:400c:c00::1a]:25: Network is unreachable
abr 23 08:44:10 MASTER postfix/smtp[2961]: 07AF3121F3A: conversation with alt1.gmail-smtp-in.l.google.com[142.250.153.26] timed out while receiving the initial server greeting
abr 23 08:44:10 MASTER postfix/smtp[2961]: connect to alt1.gmail-smtp-in.l.google.com[2a00:1450:4013:c16::1b]:25: Network is unreachable


dig -t MX gmail.com

Code:
gmail.com.		2181	IN	MX	40 alt4.gmail-smtp-in.l.google.com.
gmail.com.		2181	IN	MX	20 alt2.gmail-smtp-in.l.google.com.
gmail.com.		2181	IN	MX	30 alt3.gmail-smtp-in.l.google.com.
gmail.com.		2181	IN	MX	5 gmail-smtp-in.l.google.com.
gmail.com.		2181	IN	MX	10 alt1.gmail-smtp-in.l.google.com.
Telnet:

Code:
telnet gmail-smtp-in.l.google.com. 25
Trying 173.194.76.27...
Connected to gmail-smtp-in.l.google.com.
Escape character is '^]'.
So apparently my server is able to connect with Gmail SMTP server, however, POSTFIX fails.

Why is this?

Thanks!


EDIT: some minutes later the logs showed the problem:

Code:
This mail has been blocked because the sender is unauthenticated. 550-5.7.26 Gmail requires all senders to authenticate with either SPF or DKIM. 550-5.7.26  550-5.7.26  Authentication results: 550-5.7.26  DKIM = did not pass 550-5.7.26  SPF [master.domain.here]

Last edited by banderas20; 04-23-2024 at 02:24 AM. Reason: new info
 
Old 04-23-2024, 03:39 AM   #6
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Quote:
Originally Posted by banderas20 View Post
EDIT: some minutes later the logs showed the problem:

Code:
This mail has been blocked because the sender is unauthenticated. 550-5.7.26 Gmail requires all senders to authenticate with either SPF or DKIM. 550-5.7.26  550-5.7.26  Authentication results: 550-5.7.26  DKIM = did not pass 550-5.7.26  SPF [master.domain.here]
So your SPF or DKIM aren't configured properly.
 
Old 04-23-2024, 07:40 AM   #7
banderas20
Member
 
Registered: Aug 2018
Posts: 138

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TenTenths View Post
So your SPF or DKIM aren't configured properly.
They aren't configured at all XD.

Thanks!
 
  


Reply

Tags
aws, mail, postfix



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Set up Postfix to SEND on one local interface, and RECEIVE on another local interface? Ealric Linux - Server 4 06-07-2022 01:13 PM
Need local postfix to send NDR if local user address is not found Rincewind2 Linux - Software 0 08-08-2015 08:44 PM
how to make postfix send email to another postfix in local network (LAN)? h4k33m Linux - Server 9 06-04-2015 04:33 PM
Postfix - send mail from one local computer to another local computer Runge_Kutta Linux - Software 3 01-09-2010 07:08 AM
Postfix : mail cannot send to send outside ( can send/receive locally) bobbinsupport Linux - Networking 3 12-15-2007 10:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration