telnet timing out from aws ec2 to sendgrid - amazon-web-services

I am trying to configure listmonk with AWS EC2 and sendgrid. However I'm getting timeout while sending mails. I tried debugging using the documentation and when I try to telnet, I'm getting timeout:
# Command
telnet smtp.sendgrid.net 25
I checked the outbound settings and everything is whitlisted:
Is there anything else I need to do to telnet to smtp.sendgrid.net?

By default, AWS blocks outbound traffic on port 25, and you have to file a request to get the restriction removed.
I usually just use a different SMTP port instead of trying to get port 25 opened. SendGrid's documentation states:
SendGrid accepts unencrypted and TLS connections on ports 25, 587, &
2525. You can also connect via SSL on port 465. Many hosting providers and ISPs block port 25 as a default practice. If your Telent session
continually times out or will not connect using port 25, it is likely
that your ISP or hosting provider is blocking the port. You can
contact your host/ISP to find out which ports are open for outgoing
SMTP relay. We recommend using port 587 to avoid any rate limiting
that your server host may apply.
I suggest just switching to use port 587

Related

Cannot telnet via AWS EC2 to SMTP(MTA) server on port 25

I'm trying to test an email validation service on AWS EC2 instance, where my program would query the SMTP server (Mail Transfer Agent on port 25). For testing purposes, I replicated the program using Telnet connection, which works fine on my local machine:
telnet gmail-smtp-in.l.google.com 25
Trying 66.102.1.27...
Connected to gmail-smtp-in.l.google.com.
Escape character is '^]'.
220 mx.google.com ESMTP a20si12977453wrg.559 - gsmtp
HELO gmail.com
250 mx.google.com at your service
MAIL FROM:<testing#gmail.com>
250 2.1.0 OK a20si12977453wrg.559 - gsmtp
RCPT TO:<thisemailwillneverexist#gmail.com>
550-5.1.1 The email account that you tried to reach does not exist. Please try
550-5.1.1 double-checking the recipient's email address for typos or
550-5.1.1 unnecessary spaces. Learn more at
550 5.1.1 https://support.google.com/mail/?p=NoSuchUser a20si12977453wrg.559 - gsmtp
Telnet, however, doesn't work on EC2, as in the example below:
telnet gmail-smtp-in.l.google.com 25
Trying 74.125.133.26...
telnet: connect to address 74.125.133.26: Connection timed out
Trying 2a00:1450:400c:c08::1a...
telnet: connect to address 2a00:1450:400c:c08::1a: Network is unreachable
EC2 is running a linux instance and allows all outbound connection. My guess here is that AWS doesn't let you connect to SMTP server on port 25 to prevent spam, but I haven't seen the confirmation of that. Any suggestions how I could fix this? If AWS is too rigid, any alternative AWS-like services where I could migrate my project?
Thank you!
AWS blocks outbound traffic on port 25 by default for EC2 instances and Lambda functions (source: AWS support page).
You can place a request for removing restriction on port 25 for your EC2 instance following this link: https://aws-portal.amazon.com/gp/aws/html-forms-controller/contactus/ec2-email-limit-rdns-request. You have to be logged in your AWS account to be able to access this link.

mail smtpport configuration in Google cloud - zimbramailcow

I have installed zimbra on GCP VM. Im able to received mail from outer and inner network but unable to send mail in outer network. I have change smtp port to 2525 and define firewall but still not able to send mail.
br//
madhur
For security reasons Google blocks SMTP traffic and that is why you can't send email:
By default, Compute Engine allows outbound connections on all ports
but port 25, which is blocked because of the risk of abuse. All other
ports are open, including ports 587 and 465.
See also the documentation what kind of traffic gets always blocked by default in GCP (and you can't change it).
The only way to semd emails from you GCP instances is to use trusted 3rd party tools such as: SendGrid, Mailgun, or Mailjet.
Have a look at the documentation on how to send emails from GCP VM's, which provider is best suited for you and how to configure specific service.

Email is not working in AWS lightsail with plesk controlpanel

I tried with php mail function and the email is not sent. I activated the port 25 in the aws instance network setting but no uses.
Checked the mail settings option in the plesk Controlpanel, I got the following message
You cannot send emails from Plesk because outbound connections on TCP port 25 is blocked. Check the firewall settings or contact your hosting provider.
Please give the suggestion, how to resolve it.
You need to request to amazon to open that port, by default it is blocked..After request they open it.
Here is the link to request
https://aws-portal.amazon.com/gp/aws/html-forms-controller/contactus/ec2-email-limit-rdns-request

AWS EC2 - reverse DNS and port 25 blocked by AWS

I am trying to set up my own Email server on EC2 instance, but facing issue related reverse DNS and SMTP port 25:
Incoming Mail (SMTP/postfix) is running but is not publicly accessible at X.X.X.X:25.
Outbound mail (SMTP port 25) seems to be blocked by your network. You will not be able to send any mail. Many residential networks block port 25 to prevent hijacked machines from being able to send spam. A quick connection test to Google's mail server on port 25 failed.
Your box's reverse DNS is currently ec2-x-x-x-x.ap-south-1.compute.amazonaws.com, but it should be mail.xyz.com. Your ISP or cloud provider will have instructions on setting up reverse DNS for your box.
By googling I found Request to remove email sending limitations link, I requested by this form to AWS, but didn't getting any solution.
Please guide me on this.

Amazon SES SMTP Connection timed out

I have been trying to set up an email notification for my application using Sendmail along with SES on CentOS 6.5. As per AWS document, I have configured sendmail with SES,
The maillog says,
sendmail[29711]: s2QFCjnu027924: to=<abc#edf.com>, delay=00:52:09, xdelay=00:08:00, mailer=relay, pri=210717, relay=email-smtp.us-east-1.amazonaws.com [107.20.142.169], dsn=4.0.0, stat=Deferred: Connection timed out with email-smtp.us-east-1.amazonaws.com
All mails are being added in mailq
# sendmail -v -q
Running /var/spool/mqueue/s2QFueiS001965 (sequence 1 of 21)
<abc#edf.com> Connecting to email-smtp.us-east-1.amazonaws.com port 25 via relay.
^C
Also, I unable to do telnet to the smtp address,
# telnet email-smtp.us-east-1.amazonaws.com 25
Trying 23.21.252.142...
^C
But nmap shows port smtp (25) is open and listening,
# nmap -p 25 localhost
Starting Nmap 5.51 ( http://nmap.org ) at 2014-03-26 17:09 CET
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000080s latency).
PORT STATE SERVICE
25/tcp open smtp
Nmap done: 1 IP address (1 host up) scanned in 0.06 seconds
netstat output,
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 29708/sendmail
I have tried with EU region smtp email-smtp.eu-west-1.amazonaws.com as well, getting the same result.
There is no selinux and iptables running and security group rules are fine with EC2.
Any help would be highly appreciated !!
I was having trouble with the timeout as well. I didn't have any vpc subnet routing as thiyagu114 said was his issue, and none of clement's suggestions helped.
Found this on the Amazon info:
Important Elastic Compute Cloud (EC2) throttles email traffic over
port 25 by default. To avoid timeouts when sending email through the
SMTP endpoint from EC2, use a different port (587 or 2587) or fill out
a Request to Remove Email Sending Limitations to remove the throttle.
So switching from port 25 to 587 fixed the timeout issue for me.
When you are sending a test mail as sudo /usr/sbin/sendmail -f from#example.com to#example.com, the mail is handed over to the sendmail running on your instance.
when sendmail tried to deliver the mail to the SMART_HOST which is email-smtp.us-east-1.amazonaws.com, it wasnt able to connect to email-smtp.us-east-1.amazonaws.com and so the email was placed in the deferred queue for retrying later.
So the problem is that your sendmail instance wasnt able to talk to email-smtp.us-east-1.amazonaws.com.
Is there any network issue in your instance?
Also the document says that you need to fill Request to Remove Email Sending Limitations to remove some restrictions on port 25
Thank you Clement for your help.
I figured it out the issue. it was vpc subnet routing problem with the instance.
Now it works like a charm :-)
If you are using AWS SES as relay you should have this configuration:
Edit main.cf:
...
relayhost = email-smtp.${aws_region}.amazonaws.com:587
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_use_tls = yes
smtp_tls_security_level = encrypt
smtp_tls_note_starttls_offer = yes
...
Edit /etc/postfix/sasl_passwd
email-smtp.${aws_region}.amazonaws.com:587 SMTP_USERNAME:SMTP_PASSWORD
Edit /etc/postfix/transport
* smtp:email-smtp.${aws_region}.amazonaws.com:587
Pay attention that you have to specify port on all places, even in transport.
execute postmap
postmap /etc/postfix/sasl_passwd /etc/postfix/transport
restart postfix
service postfix restart
And it'll work. The rest of configuration you can find at http://docs.aws.amazon.com/ses/latest/DeveloperGuide/postfix.html
If you are sending to Amazon SES from an Amazon EC2 instance via port 25 and you cannot reach your Amazon SES sending limits or you are receiving time outs then it's probably because Amazon EC2 imposes default sending limits on email sent via port 25 and throttles outbound connections if you attempt to exceed those limits.
Solutions -
You can connect to Amazon SES using ports 465 or 587, neither of which is throttled.
OR
To remove the limits, submit an Amazon EC2 Request to Remove Port 25 Limitations (https://aws-portal.amazon.com/gp/aws/html-forms-controller/contactus/ec2-email-limit-rdns-request).