Unable to use smtp.gmail.com via telnet - email

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)

Related

Trying to connect to Gmail's SMTP

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.

Having authentication error while using msmtp

I am using msmtp to sent emails but getting authentication error although my login credentials were right.
my msmtprc file contains
defaults
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
account default
host smtp.gmail.com
port 25
auth on
user *******#gmail.com
password *********
from **********#gmail.com
logfile /var/log/msmtp.log
on running this command on terminal
echo -e "Subject: Test Mail\r\n\r\nThis is my first test email." |msmtp --debug --from=default -t vikrantgoutam16#gmail.com
I get the following errors
msmtp: authentication failed (method PLAIN)
msmtp: server message: 535-5.7.8 Username and Password not accepted. Learn more at
msmtp: server message: 535 5.7.8 https://support.google.com/mail/?p=BadCredentials b14sm68898705pfi.92 - gsmtp
msmtp: could not send mail (account default from /etc/msmtprc)
I just had the same issue. I have a Debian 10 32bit with PHP 7.3.14-1, and the /etc/msmtprc file has...
account <myusername>#gmail.com
host smtp.gmail.com
port 587
tls on
tls_starttls on
auth on
user <myusername>
password <plain-password>
from <username>#gmail.com
account default : <username>#gmail.com
This configuration sends the email with no errors using smtp.gmail.com, then I have a GCE (Google Compute Engine) with Debian 10 64bit and PHP 7.3.14-1, with the exact same configuration file and it does not work.
I enabled the 2-step verification method and generated a 16 character password for my script, with the App Password, the GCE just worked. Of course the 32bit machine is not able to send emails anymore, but my priority was the GCE machine. The configuration file on GCE is...
# Set default values for all following accounts.
defaults
port 587
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
account gmail
host smtp.gmail.com
from <myusername>#gmail.com
auth on
user <myusername>#gmail.com
password <16 character password from Gmail>
# Set a default account
account default : gmail
It's probably worth mention that the 32bit machine has gCloud SDK and it's fully capable of login and connect to the GCE instance.
Following the guide on the arch wiki I realized that I did not have chmod setting.
I technically copied and pasted the settings in the example making these changes:
from
user
password
<< deleted the freemail service section >>
Once I set this parameter solution worked for me.

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!

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.