Why can I not do an SMTP telnet to gmail? - email

I have tried connecting and using telnet to a gmail service for testing:
telnet gmail-smtp-in.l.google.com 25
Yet it says
Connecting to gmail-smtp-in.l.google.com failed.. Could not open connection to the host, on port 25: Connect Failed
Is this because of my firewall or am I doing something wrong?
I have tested this at work and at home and I am still unable to telnet in.
Yet, when I do an SMTP test using mxtoolbox, it seems that they can telnet in.
Is there something I am missing?
I am trying to do an SMTP test using Telnet.

Your ISP may be blocking outgoing SMTP connections to smtp (25) port as outgoing spam prevention.
Can you telnet smtp (25) port on any email host beyond your ISP network?
Can you telnet smtp.gamil.com 587?
[Port 587 is intended for client to server SMTP sessions, gmail supports it]

Related

Setting up hMailServer to send and receive email

I'm trying to configure hMailServer on my computer to be able to send email out and also receive emails. I'm not sure if I have everything set up correctly as some tests works and some others do not so I am confused.
I have already set up in the DNS of my domain these 3 MX records:
mail.example.com
smtp.example.com
imap.example.com
Each one of those records points to the domain name of my server. I am able to connect to the web server of my domain. In my router, I have forwarded ports 25, 110, 143, 465 and 587 to my local computer running the hMailServer application. When running a port check on the web, it looks like port 25, 110 and 465 are blocked, but the rest are not.
If I open my Mozilla Thunderbird mail client, I set up an account I created in hMailServer for the domain in question.
I have also allowed the hMailServer application through my Windows firewall for both the private and public networks. I did the same for the Thunderbird email client.
I can locally send emails to myself and other local domains set up in hMailServer. However, I cannot send or receive any email to/from external recipients, like to/from Gmail or Hotmail for example. I'm getting this error message:
Error Type: SMTP
Connection to recipients server failed.
Error: Host name: 1.1.1.1 (edited) message: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Here are the TCP/IP ports summary in hMailServer:
The second part of my question is once I can actually send and receive email to/from external domains, how would I secure the connection (SSL/TSL...)? I already have a SSL certificate for my web server (example.com and www.example.com). Do I just need to generate another one for say mail.example.com or do email servers use a different kind of certificate?

Send Grid SMTP server sometimes can not connect

I am building a Jenkins server on my AWS EC2 instance. After building finish, I want to send email to stakeholder.
I am using STMP with smtp.sendgrid.net in port 587.
But I sometime can not send email. The log from jenkins says
MessagingException message: Could not connect to SMTP host:
smtp.sendgrid.net, port: 587
I access to EC2 instance and telnet to sendgrid. It says:
[hostname#domain ~]$ telnet smtp.sendgrid.net 587
Trying 161.202.148.179...
telnet: connect to address 161.202.148.179: Connection timed out
Trying 161.202.148.182...
telnet: connect to address 161.202.148.182: Connection timed out
Trying 169.38.103.39...
Connected to smtp.sendgrid.net.
Escape character is '^]'.
220 SG ESMTP service ready at ismtpd0004p1maa1.sendgrid.net
I understand that mean I can only access to some ip coming from smtp.sendgrid domain. I am sure to open all outbound rules for EC2. Because the problem happens sometimes, so anyone could give me any suggestion for this situaions.I intend to use IP instead of domain, but it just a workaround, IP can change anytime.
Please help me.
I had a similar issue, if your EC2 outbound rules are opened then you should ensure that you provide SMTP authentication along with your SMTP server and SMTP port and your DNS resolvers are good enough.
Sendgrid expects username and password.
username: it's "apikey", It might have to be encoded in base64 "YXBpa2V5".
password: it's your API Key, get it from Sendgrid and save it here. It might have to be encoded in base64.
I tried base64 encoded and it didn't work, so I tried without the encoding and it worked.
If your problem is not related to the authentication, you could review your DNS resolver, probably the problem would be there.

Query reg SMTP port

Hi am having a confusion reg SMTP ports. I have configured an application in my local machine to use gmail's smtp server by getting the details from here - https://www.siteground.com/kb/google_free_smtp_server/ and am able to trigger emails without any issues.
When I set the same application in a windows server and use the same smtp settings the emails aren't going and I keep getting errors like "unable to connect to smtp port 465". So is the port being mentioned here - 465 - is this port being used from my machine to connect to gmail's smtp server or is this port being referred to the port in the machine where gmail's smtp server is hosted?

IIS SMTP: connection open, but no 220 response

I'm trying to send an email to my IIS (6) SMTP service.
The domain mycustomer.myserver.comis added to the domains list of the SMTP service. Port 25 is open, I can telnet there.
telnet mycustomer.myserver.com 25, gives no errors, but no message either. (other mail servers do show 220).
SMTPDIAG confirms this: Error: Expected "220". Server is not accepting connections.
Failed to submit mail to mycustomer.myserver.com.
Do I need any further configuration of my IIS SMTP to get this to work?
At this point, I do not have MX records, but I don't think that is the problem?
OK found it:
Allowed connections were restricted to localhost, as configured under Access > Connection control.

Using SMTP, Gmail, and STARTTLS

So I'm learning about SMTP and am trying to use telnet to send some mail over SMTP.
I've easilly been able to send mail to my gmail account via:
$ host gmail.com
...
gmail.com mail is handled by 5 gmail-smtp-in.l.google.com.
...
$ telnet gmail-smtp-in.l.google.com 25
Trying 74.125.142.27...
...
Connected to gmail-smtp-in.l.google.com.
...
HELO <me#test.com>
...
However, I'm having trouble sending from my gmail account. From what I understand about SMTP, I should be using SMTP to send mail from < mygmailaddress#gmail.com >
to the outgoing gmail SMTP servers, which in turn use SMTP to transfer the mail to the receivers incoming SMTP server ect.
However, I'm having difficulties. If I telnet into smtp.gmail.com via port 465 (gmail outgoing smtp mail server canonical), I'm immediately disconnected after starting with HELO <blah#blah.com>, or asked to STARTTLS. I can't find answers on how to proceed.
Any help is appreciated.
Sidenote: Currently I'm using Starbucks free Wi-Fi to access the internet. I'm actually unable to telnet directly from my computer (No route to host error). Instead, it only works if I ssh into a remote linux box on my school's network first, then telnet from there. Any idea why this is?
Thanks!
First of all, it looks like you're using the wrong port. Gmail exposes port 465 for SMTP over SSL and port 587 for SMTP with STARTTLS, as documented here. The difference between these two is that SMTP over SSL first establishes a secure SSL/TLS connection and conducts SMTP over that connection, and SMTP with STARTTLS starts with unencrypted SMTP and then switches to SSL/TLS. This is why you don't get a response to your HELO.
$ telnet smtp.gmail.com 587
Trying 74.125.25.108...
Connected to gmail-smtp-msa.l.google.com.
Escape character is '^]'.
220 mx.google.com ESMTP fr1sm24834956pbb.26 - gsmtp
HELO <me#test.com>
250 mx.google.com at your service
STARTTLS
220 2.0.0 Ready to start TLS
But even if you telnet to port 587 you still aren't going to be able to send any email by hand. In order to do anything interesting you will have to STARTTLS, and you won't be able to handle the SSL/TLS binary protocol to negotiate the encryption.
The telnet client will not negotiate a TLS session for you. You should use another tool, such as OpenSSL's s_client. The following issues the STARTTLS command for you and handles the TLS negotiation:
$ openssl s_client -starttls smtp -connect smtp.gmail.com:587 -crlf
Alternatively, you could connect directly to the SMTPS port:
$ openssl s_client -connect smtp.gmail.com:465 -crlf