Getting SMTP 504 .5.7.4 "Unrecognized authentication type" trying to send a mail with Outlook 365 - smtp

I am trying to setup the ability to send emails using my Office365 email account from my .net site. Before i code this, i want to make sure its possible to do so and hence using a SMTP debugging tool i got from the internet. I keep getting 504 5.7.4 Unrecognized authentication type error.
Settings:
server: smtp.office365.com
Port: 587
User: myemail#mysite.com
Pass: mypassword
Requited Authentication: true
From Email: myemail#mysite.com
To Email: User: myemail#mysite.com
When i post this request i get the following logs:
Connecting to mail server.
Connected.
220 abc.outlook.office365.com Microsoft ESMTP MAIL Service ready at Sat, 15 May 2021 19:22:41 +0000
EHLO EC2AMAZ-GODJD
250-abc.outlook.office365.com Hello [1.1.1.1]
250-SIZE 157286400
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-8BITMIME
250-BINARYMIME
250-CHUNKING
250 SMTPUTF8
AUTH LOGIN
504 5.7.4 Unrecognized authentication type [abc.prod.exchangelabs.com]
Forcing disconnection from SMTP server.
QUIT
221 2.0.0 Service closing transmission channel
Disconnected.
What i have tried
I read that outlook has "Security Defaults" that blocks SMTP. I have turned this off.
What might be going wrong?

I have ran into this problem in the past. What l did back then was to enable STARTTLS, and declare the authentication will be sent in plain text.
Let me know if it works.

Related

telnet smtp.gmail.com returns no response

I can't connect to my smtp gmail from my unix environment,
when I do telnet smtp.gmail.com I get response
Trying 74.125.68.108...
telnet: connect to address 74.125.68.108: Connection timed out
Trying 2404:6800:4003:c02::6d...
How do I debug this?
Gmail requires SMTP communication with their server to be encrypted. You're opening up a connection to Gmail's server on port 465, unfortunately you won't be able to communicate with it in plaintext as Gmail require you to use STARTTLS/SSL encryption for the connection.
Try this:
telnet smtp.gmail.com 587
OR using Linux or OSx, you can try to use 465 with openssl.
openssl s_client -connect smtp.gmail.com:465
You should get lots of information on the SSL session and the response:
220 mx.google.com ...
Type in
HELO smtp.gmail.com
and you'll receive:
250 mx.google.com at your service
From there it is not quite as straightforward as just sending SMTP messages because Gmail has protections in place to ensure you only send emails appearing to be from accounts that actually belong to you. Instead of typing in "Helo", use "Ehlo". I don't know much about SMTP so I cannot explain the difference, and don't have time to research much. Perhaps someone with more knowledge can explain.
Then, type:
auth login
And you will receive the following:
334 VXNlcm5hbWU6
This is the word "Username" encoded in Base 64. Using a Base 64 encoder such as this one, encode your user name and enter it. Do the same for your password, which is requested next. You should see:
235 2.7.0 Accepted
And that's it, you're logged in.
There is one more oddity to overcome if you're using OSx/Linux terminals. Just pressing the "ENTER" key does not result in a CRLF which SMTP needs to end a message. You have to use "CTRL+V+ENTER". So, this should look like the following:
^M
.^M
250 2.0.0 OK
Not a answer,but just posting the outcomes of above suggestions.
telnet smtp.gmail.com 465
Trying 74.125.68.108...
telnet: connect to address 74.125.68.108: Connection timed out
Trying 2404:6800:4003:c02::6c...
telnet smtp.gmail.com 587
Trying 74.125.68.108...
telnet: connect to address 74.125.68.108: Connection timed out
Trying 2404:6800:4003:c02::6c...

OpenCart emails not sending

My OpenCart website uses SendGrid as its email sending system. This all worked correctly up until recently. When using functions which require sending an email to the admin (eg. new order alert emails, creating a new account), I've been getting this error:
Notice: Error: Password not accepted from server! in .../system/library/mail.php on line 251
In OpenCart Settings > Mail, my settings are as follows:
Mail Protocol: SMTP
SMTP Host: smtp.sendgrid.net
SMTP Username: <username>
SMTP Password: <pass>
SMTP Port: 25
SMTP Timeout: 5
This is according to SendGrid's documentation: https://sendgrid.com/docs/Classroom/Basics/Email_Infrastructure/smtp_ports.html
Can anyone advise? These settings work on my localhost. I contacted the host to see if they blocked the SMTP port, but they replied that they don't have the ability to block the port since the SMTP host is not their website, but instead SendGrid.
This is not a port problem. I had the same issue: the SendGrid documentation is wrong. Documentation screenshot reports SendGrid username, but you have to use 'apikey'. I suggest to use port 587.

getting "530 5.7.0 Must issue a STARTTLS command first." error when sending mail via netcat

I'm trying to send an email with netcat, this is what i get:
****-MacBook-Pro:~ ***$ nc smtp.gmail.com 25
220 mx.google.com ESMTP h8sm66301168eew.16 - gsmtp
Helo gmail.com
250 mx.google.com at your service
MAIL FROM: <******#gmail.com>
530 5.7.0 Must issue a STARTTLS command first. h8sm66301168eew.16 - gsmtp
what is STARTTLS command and what do i need to do with it?
STARTTLS is an extension to plain text communication protocols, which offers a way to upgrade a plain text connection to an encrypted (TLS or SSL) connection instead of using a separate port for encrypted communication.
http://en.wikipedia.org/wiki/STARTTLS
The smtp server is saying it won't accept plain text connections.
You basicaly just need to specify that you're using TLS.
Use EHLO instead of HELO. This will start 250-STARTTLS.

Exchange SQL Server 2008 Database Mail issue

In my web application I have created a mail sender class and set the configurations of web.config file like this:
<mailSettings>
<smtp deliveryMethod="PickupDirectoryFromIis">
<network host="smtp.domain.com"
port="587"
userName="mail#domain.com"
password="password"/>
</smtp>
</mailSettings>
This is sending email. But SQL Server database mail can not send mail with the same account info.
Only one difference is PickupDirectoryFromIis .
Is there any setting on exchange server?
In the SQL Server Logs the errors are following.
Message
The mail could not be sent to the recipients because of the mail
server failure. (Sending Mail using Account 2 (2012-09-30T16:55:04).
Exception Message: Cannot send mails to mail server. (The SMTP server
requires a secure connection or the client was not authenticated. The
server response was: 5.7.1 Client was not authenticated).
Looks like this is a Authentication issue or port no issue.
Authentication Issue:
—————————-
Please make sure you have put the information as explained below:
Server name: smtp.gmail.com ( this is really important)
port no: 587 ( on many website this is given as 465 which is wrong, use 587 )
Check : This server requires a secure connection
Check Basic Authentication
username: youremailid#gmail.com ( should have gmail.com)
password: XXXXXXXXXXXXX
confirm password: confirm your password
Port No Issue:
——————–
Make sure port 587 is opened in your machine if you are following above example. If you are using any other port number (usually its port 25) to set up database mail in your office, make sure you speak with your security team and ask them to unblock port 25. Once they unblock port 25, your databasemail will work.
Network Connectivity:
—————————–
Also check network connectivity from your machine, if you can connect to internet from your machine on which you are testing your database mail. To test, do the following
Start- Run- type cmd – Hit Enter
Type ping gmail.com -t and then hit enter.
If output displays as Request timed out, it actually means there is network connectivity problem. Otherwise, your network connectivity is good.

Connecting to smtp.gmail.com via command line

I am in the process of writing an application that sends mail via an valid GMail user ID and password.
I just wanted to simulate the SMTP connection on my Windows XP command line, and when I telnet smtp.gmail.com at 465 port - I don't see any thing. A blank command window with title Telnet smtp.gmail.com opens with cursor. When I type in EHLO or usual SMTP handshake commands, the prompt just closes.
I am unable to figure out whats going wrong and where. I tried connecting to 587, it does not connect in telnet at all. Could anyone please clarify if I am doing something wrong?
Using Linux or OSx, do what Sorin recommended but use port 465 instead. 25 is the generic SMTP port, but not what GMail uses. Also, I don't believe you want to use -starttls smtp
openssl s_client -connect smtp.gmail.com:465
You should get lots of information on the SSL session and the response:
220 mx.google.com ...
Type in
HELO smtp.gmail.com
and you'll receive:
250 mx.google.com at your service
From there it is not quite as straightforward as just sending SMTP messages because Gmail has protections in place to ensure you only send emails appearing to be from accounts that actually belong to you. Instead of typing in "Helo", use "Ehlo". I don't know much about SMTP so I cannot explain the difference, and don't have time to research much. Perhaps someone with more knowledge can explain.
Then, type "auth login" and you will receive the following:
334 VXNlcm5hbWU6
This is essentially the word "Username" encoded in Base 64. Using a Base 64 encoder such as this one, encode your user name and enter it. Do the same for your password, which is requested next. You should see:
235 2.7.0 Accepted
And that's it, you're logged in.
There is one more oddity to overcome if you're using OSx or Linux terminals. Just pressing the "ENTER" key does not apparently result in a CRLF which SMTP needs to end a message. You have to use "CTRL+V+ENTER". So, this should look like the following:
^M
.^M
250 2.0.0 OK
For OSX' terminal:
openssl s_client -connect smtp.gmail.com:25 -starttls smtp
Start session from terminal:
openssl s_client -connect smtp.gmail.com:25 -starttls smtp
The last line of the response should be "250 SMTPUTF8"
Initiate login
auth login
This should return "334 VXNlcm5hbWU6".
Type username
Type your username in base64 encoding (eg. echo -n 'your-username' | base64)
This should return "334 UGFzc3dvcmQ6"
Type password
Type your password in base64 encoding (eg. echo -n 'your-password' | base64)
Success
You should see "235 2.7.0 Accepted" and you're are successfully logged in
Gmail require SMTP communication with their server to be encrypted. Although you're opening up a connection to Gmail's server on port 465, unfortunately you won't be able to communicate with it in plaintext as Gmail require you to use STARTTLS/SSL encryption for the connection.
Jadaaih, you can connect send SMTP through CURL - link to Curl Developer Community.
This is Curl Email Client source.
Check this post in lifehacker : Geek to Live: Back up Gmail with fetchmail . It uses a command line program. Check and see if it helps. BTW why are you using command line when there are many other nice alternatives?
tcp/465 was initially intended for establishing the SSL(and newer TLS) layer first, and inside doing cleartext or plain old protocols (smtp here)
tcp/587 was intended as a replacement to default tcp/25 port initially when spammers and mass mailing attacks commenced like a decade or more ago, but also during those infamous AOL ages, when some funny ISP had some blocks on default ports outbound (such as that tcp/25) for denying their own customers (AOL) to mass-send emails/spam back then, but AOL-customers needing to use alternative mail-accounts and mail-providers still needed to send their mails from AOL-internet connections, so they could still connect to tcp/587 and do simple smtp on it back then.
The deal with the STARTTLS way to do smtp is to use the two well known originally plain-text tcp/25 and tcp/587 ports, and only when the initial clear-text connect suceeded, to then START the TLS layer (thus STARTTLS) from there on, having a secured connection from that point onwards.
As for debugging these kind of things maybe via command-line tools, for example for windows there is the historical blat command line mailer (smtp), which up till today cant do TLS (STARTTLS) so it can only use plain-text smtp to send its mails.
http://www.blat.net/
Then there are numerous projects freeware and open source software that have more capabilities and features, such as
smtp client: mailsend # googlecode
http://code.google.com/p/mailsend/
smtp client: msmtp # sourceforge (related to mpop below)
http://msmtp.sourceforge.net/
pop3 client: mpop # sourceforge
http://mpop.sourceforge.net/
How to connect to "Google SMTP mail server" from the command line?
1] SSL connect command
openssl s_client -connect {{server_name}}:{{server_port}} -crlf -quiet -starttls smtp
with variables
server_name: smtp.gmail.com
server_port: 587
user_name__hash: echo -n '{{user_name}}' | base64
user_password__hash: echo -n '{{user_password}}' | base64
2] SMTP mail server commands - every command in one line
auth login
{{user_name__hash}}
{{user_password__hash}}
helo {{server_name}}
mail from: <{{message_from}}>
rcpt to: <{{message_to}}>
DATA
from: <{{message_from}}>
to: <{{message_to}}>
subject:{{message_subject}}
Content-Type: text/html; charset='UTF-8'; Content-Transfer-Encoding: base64;
MIME-Version: 1.0
{{message_content}}
.
quit
Try this:
telnet smtp.gmail.com 587
gmail uses an encrypted connection. So, even after you establish a connection, you wont be able to send any email. The encryption is a little complex to manage. Try using openssl instead.
The thread below should help-
How to send email using simple SMTP commands via Gmail?