Trying to connect to Gmail's SMTP - email

I'm trying to connect to Gmail's SMTP.
First, I get its smtp server.
dig mx gmail.com
gmail-smtp-in.l.google.com is the one with the lowest priority.
I think I could try telnet'ing to that address at this point, however Gmail requires TLS, and telnet does not support it.
I try openssl then, for ports 25, 587 and 465:
openssl s_client -starttls smtp -connect gmail-smtp-in.l.google.com:587
The command above returns nothing... why?
However, this one does connect:
openssl s_client -starttls smtp -connect smtp.gmail.com:587
Why?

The server of gmail-smtp-in.l.google.com is not accessible on 587 port, but it is on 25.

Related

Vanilla forum "SMTP Error: Could not connect to SMTP host."

Since I upgraded my production site (Linux, Apache) from Vanilla 2.2.1 on PHP 5.5 to Vanilla 2.3.1 on PHP 7.0, my site cannot send emails - failing with the message "SMTP Error: Could not connect to SMTP host."
My settings are:
SMTP Host: smtp.gmail.com
SMTP User: [my email]
SMTP Password: [my password]
SMTP Port: 465
SMTP Security: SSL
I read many similar questions on SO and tried the following:
Confirm OpenSSL is enabled
Confirm with the hosting provider that port 465 is not blocked on their firewall
Telnet test on the hosting server gives this:
$ telnet smtp.gmail.com 465
Trying 108.177.97.108...
Connected to smtp.gmail.com.
Escape character is '^]'.
Connection closed by foreign host.
Switching to a different hosting server (same provider) with PHP 7.0, but same error
Not sure if this will be useful information, but when I try TLS with port 587 it gives another error - "Language string failed to load: tls"
My local test site with Vanilla 2.3.1 on PHP 7.0 (Windows, IIS), an identical copy of the production, can send emails without problem with the above SSL settings.
Is there anything else I can try? Any help is appreciated!

Unable to use smtp.gmail.com via telnet

All I did is connected to smtp.gmail.com at port 587 via telnet as:
telnet smtp.gmail.com 587
And typed:
EHLO smtp.gmail.com
And this was the output I got:
250-smtp.gmail.com at your service, [14.97.86.28]
250-SIZE 35882577
250-8BITMIME
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
Then when I used telnet for the 1st time and typed AUTH LOGIN, I got something like:
334 VXNlcm5hbWU6
I successfully sent a mail for the 1st time. And exited my telnet program with a QUIT command.
BUT from the 2nd time and onwards, whenever I type AUTH LOGIN, all I get is:
530 5.7.0 Must issue a STARTTLS command first. x79sm16871877pfi.47 - gsmtp
Even after this when I type:
STARTTLS
I get:
220 2.0.0 Ready to start TLS
But after that if I give any other command, my connection is automatically closed and all I get is this:
FConnection closed by foreign host.
What have I messed up? I need to get this thing working. Please help!
If you are not using OAuth2 (https://developers.google.com/identity/protocols/OAuth2) Google classify your access as an access from a less secure app.
If you want to enable mail sending from telnet you can enable less secure app into your gmail account (https://support.google.com/accounts/answer/6010255?hl=en)

mail is not working on my PC

Tried to send an email to myself in a bash script from Ubuntu (12.04) command line, it will not send. I even used wireshark to snoop traffic on port 25, don't even see tcp session got established.
mail -s "Subject" xxxxx#yahoo.com < msg.txt
It's supposed to be very simple: just find the server from the email address (xxxxx#yahoo.com), set up a TCP connection and follow the SMTP protocol. It doesn't even try to establish an TCP connection.
Any ideas? Thanks.
use the sendmail program. It's a lot simpler :)
sudo apt-get install sendmail
sudo sendmailconfig
echo testmail | sendmail address#gmail.com

Testing Zoho Mail server from ssh

I want to ensure our server able to connect and send emails using Zoho's service. How do I test this purely via terminal connected to my server's ssh?
Server's setting is Linux Ubuntu but a platform agnostic answer would be most appreciated.
Following is Zoho's mail server details:
https://www.zoho.com/mail/help/zoho-smtp.html
Connect to smtp.zoho.com on the port 25 for establishing smtp connection and send mails. For SSL/TLS connections, openssl library should be used for establishing smtp connection
For simple smtp connection
telnet smtp.zoho.com 25
For SSL connection
openssl s_client -connect smtp.zoho.com:465
For TLS connection
openssl s_client -starttls smtp -connect smtp.zoho.com:587 -crlf -ign_eof
Hope this suffices

How to specify port number when sending mail with postfix?

I've uncommented the 'submission' line in master.cf and I can 'telnet example.com 587' on my mail server with no problem but how do I send mail from the command line of the client to the postfix server over port 587?
My server is hosted as a digitalocean droplet (centos instance) on the internet and my client is my home laptop.
Each time I try to deliver a message with the 'mail user#example.com' command I instantly receive a rejection message because my isp blocks port 25.
Any help greatly appreciated :)
mail command will drop the mail to the SMTP server running on your home laptop and the SMTP server running on your home laptop is not configured i guess. So it is trying to deliver the mail by doing an MX lookup (i.e to port 25 of your MX server). If you want to do any smtp tests please try using swaks tool.
# For eg. to authenticate and send mail from your mail server, you will have to use
swaks -f you#example.com -t someone#yahoo.com -s example.com -p 587 --auth-user you#example.com --auth-pass somepass
# -f from
# -t to
# -s server
# -p port
# --auth-user username
# --auth-pass password
More info here Hope that helps.