Author |
|
dineshfbmaster Newbie
![Newbie](forum_images/1_star_rating.gif)
![Avatar](avatars/abstract.jpg)
Joined: 25 July 2020 Location: India
Online Status: Offline Posts: 2
|
Posted: 25 July 2020 at 9:03am | IP Logged
|
|
|
Hi,
We are using Google Auth2 for sending email and getting below error.
Error: The server has responded with negative reply. The server responded: 555 5.5.2 Syntax error
sample code for c# as below
Smtp mailer = new Smtp();
mailer.SmtpServers.Add("smtp.gmail.com", null, xoauthKey, AuthenticationMethods.SaslOAuth2);
// Logging is not necessary but useful for debugging.
mailer.Log.Enabled = true;
mailer.Log.Filename = @"C:\Temp\log.txt";
mailer.Log.HidePasswords = false;
mailer.Log.Clear();
Console.WriteLine(mailer.IsSslConnection);
mailer.From.Email = userEmail + " <" + userEmail + ">"; // + " <" + userEmail + ">"; //+ "<" + model.FromEmail + ">"
mailer.From.DisplayName = "Dinesh Bhai";
mailer.To.Add("swapnalchonkar@gmail.com");
mailer.Subject = "empty email to myself";
mailer.BodyHtmlText = "Hello World !!!";
// For async/await version, see GoogleOAuthWinForms sample.
mailer.Send();
Entire logs as below
[21:29:59.76] [INFO] Assembly version: 12.1.1 build 620 for .NET 4.5.
[21:29:59.73] [INFO] Will send mail message.
[21:30:00.03] [INFO] Will resolve host "smtp.gmail.com".
[21:30:00.14] [INFO] Host "smtp.gmail.com" resolved to IP address(es) 74.125.68.108.
[21:30:00.23] [INFO] Will connect to host "smtp.gmail.com" on port 25.
[21:30:00.37] [INFO] Socket connected to IP address 74.125.68.108 on port 25.
[21:30:00.69] [RECV] 220 smtp.gmail.com ESMTP e191sm9791238pfh.42 - gsmtp\r\n
[21:30:00.74] [INFO] Connected to mail service at host "smtp.gmail.com" on port 25 and ready.
[21:30:00.75] [INFO] Will send Hello command (HELO or EHLO).
[21:30:00.78] [SEND] EHLO [192.168.1.104]\r\n
[21:30:00.99] [RECV] 250-smtp.gmail.com at your service, [103.26.226.119]\r\n250-SIZE 35882577\r\n250-8BITMIME\r\n250-STARTTLS\r\n250-ENHANCEDSTATUSCODES\r\n250-PIPELINING\r\n250-CHUNKING\r\n250 SMTPUTF8\r\n
[21:30:01.02] [INFO] SMTP Hello completed.
[21:30:01.03] [INFO] Notify server that we are ready to start TLS/SSL negotiation.
[21:30:01.07] [SEND] STARTTLS\r\n
[21:30:01.29] [RECV] 220 2.0.0 Ready to start TLS\r\n
[21:30:01.31] [INFO] Will start TLS/SSL negotiation sequence.
[21:30:01.64] [INFO] TLS/SSL negotiation completed.
[21:30:01.65] [INFO] Will send Hello command (HELO or EHLO).
[21:30:01.67] [SEND] EHLO [192.168.1.104]\r\n
[21:30:01.88] [RECV] 250-smtp.gmail.com at your service, [103.26.226.119]\r\n250-SIZE 35882577\r\n250-8BITMIME\r\n250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH\r\n250-ENHANCEDSTATUSCODES\r\n250-PIPELINING\r\n250-CHUNKING\r\n250 SMTPUTF8\r\n
[21:30:01.91] [INFO] SMTP Hello completed.
[21:30:01.92] [INFO] Will login as "".
[21:30:01.97] [INFO] Will try SASL XOAUTH2 authentication method.
[21:30:01.98] [SEND] AUTH XOAUTH2 dXNlcj1kaW5lc2hmYm1hc3RlckBnbWFpbC5jb20BYXV0aD1CZWFyZXIgZXlKaGJHY2lPaUpTVXpJMU5pSXNJbXRwWkNJNkltSTJNMlZsTUdKbE1Ea3paRGxpWXpNeE1tUTVOVGhqT1RrMk5tUXlNV1l3WXpobU5tSmlZbUlpTENKMGVYQWlPaUpLVjFRaWZRLmV5SnBj M01pT2lKaFkyTnZkVzUwY3k1bmIyOW5iR1V1WTI5dElpd2lZWHB3SWpvaU16YzJNekV6Tmpjd05UZzJMVGh2TjJkelpHWXdiWFJuYm5KemJuQnliRFE1ZFdVMmIyUnlNSEkxTjI0MkxtRndjSE11WjI5dloyeGxkWE5sY21OdmJuUmxiblF1WTI5dElpd2lZWFZrSWpv aU16YzJNekV6Tmpjd05UZzJMVGh2TjJkelpHWXdiWFJuYm5KemJuQnliRFE1ZFdVMmIyUnlNSEkxTjI0MkxtRndjSE11WjI5dloyeGxkWE5sY21OdmJuUmxiblF1WTI5dElpd2ljM1ZpSWpvaU1UQTBNVE0zTnpZd01UZzJNRFkzTnpNMk56ZzVJaXdpWlcxaGFXd2lP aUprYVc1bGMyaG1ZbTFoYzNSbGNrQm5iV0ZwYkM1amIyMGlMQ0psYldGcGJGOTJaWEpwWm1sbFpDSTZkSEoxWlN3aVlYUmZhR0Z6YUNJNklsQjJia0ZNU1ZSa1ZqZFBUMjlQVmxOcWJVbFFObEVpTENKcFlYUWlPakUxT1RVMk9USTJOREFzSW1WNGNDSTZNVFU1TlRZ NU5qSTBNSDAuQmFNb0ROVTVvaFN4TlVLZFdoU29PMXpISy1uMEpPU2VkMThUZ0h5NUVaYlI2dDhZQ1Z0ZjBiRmNjNHNCMmh4Y2hGTEktaVdDVWpmbFhfeVA0VHJpaTQxX212OFY5Rmtlam9sNm5iNl9ZLVhpTENkS3NabHRzZWV2Y2wzdHR4d1pSdXVzaGY0WW1yNUlp ZVBseVFXa0VfYTIyTkd0WFZzMl9oTnlrZlRJRGJrdlE4TGxod2paeENoMG5ZUmE1ZS1fLTN4YjRDNE9rTG1HVXI1LVNBZl9ZcW9SYWVIZXdDUG9qR0l2dzlKZVF4cEhUTWNGdWFqM19pVFRod1RVVzBrbGFpX19VOHJydjFkejBncTNWZUxRb3FqdVkxdUFKTVE5XzV6 REtheG5rQWpYSHBtcFl0OVRHTzdMZVpfdnVNenJqOWVydXExMV96QnBLWVBkbWJxWHNnAQE=\r\n
[21:30:02.19] [RECV] 555 5.5.2 Syntax error, goodbye. e191sm9791238pfh.42 - gsmtp\r\n
[21:30:02.42] [INFO] Will disconnect from host "smtp.gmail.com".
[21:30:02.49] [INFO] Disconnected from host "smtp.gmail.com".
[21:30:02.50] [INFO] Error: The server has responded with negative reply. The server responded: 555 5.5.2 Syntax error, goodbye. e191sm9791238pfh.42 - gsmtp.
|
Back to Top |
|
|
Igor AfterLogic Support
![AfterLogic Support](forum_images/5_star_rating.gif)
Joined: 24 June 2008 Location: United States
Online Status: Offline Posts: 6082
|
Posted: 27 July 2020 at 12:24am | IP Logged
|
|
|
Looks like xoauthKey isn't valid, but it's not clear from your code how you're obtaining one. Can you post the relevant code?
--
Regards,
Igor, Afterlogic Support
|
Back to Top |
|
|
dineshfbmaster Newbie
![Newbie](forum_images/1_star_rating.gif)
![Avatar](avatars/abstract.jpg)
Joined: 25 July 2020 Location: India
Online Status: Offline Posts: 2
|
Posted: 27 July 2020 at 5:33am | IP Logged
|
|
|
Hi Igor,
Kindly find below source code.
public static void Main(string[] args)
{
// Uncomment and set your key if you haven't specified it in app.config or Windows registry.
MailBee.Global.LicenseKey = "MN120-****************************-****";
// You get these in Google Developer Console.
string yourAppClientID = "************-********************************.apps.googleusercontent.com";
string yourAppClientSecret = "******-*****************";
string userEmail = "<**************@gmail.com>"; //"**************@gmail.com";
//We will get this token information from the Chrome extension
string _token = "eyJhbGciOiJSUzI1NiIsImtpZCI6ImI2M2VlMGJlMDkzZDliYzMxMmQ5NThjOTk2NmQyMWYwYzhmNmJiYmIiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJhY2NvdW50cy5nb29nbGUuY29tIiwiYXpwIjoiMzc2MzEzNjcwNTg2LThvN2dzZGYwbXRnbnJzbnBybDQ5dWU2 b2RyMHI1N242LmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwiYXVkIjoiMzc2MzEzNjcwNTg2LThvN2dzZGYwbXRnbnJzbnBybDQ5dWU2b2RyMHI1N242LmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwic3ViIjoiMTA0MTM3NzYwMTg2MDY3NzM2Nzg5Iiwi ZW1haWwiOiJkaW5lc2hmYm1hc3RlckBnbWFpbC5jb20iLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiYXRfaGFzaCI6IkxFdFo2MTRNOW9vek9FMkdwNTNSUmciLCJpYXQiOjE1OTU4MDEwMTAsImV4cCI6MTU5NTgwNDYxMH0.WZqOl_zJ6a7FcYkcPrpcLQsrq0jttlQ1 nRL_usaVxxyDk-J1uZF6fk_-ORa9Jobyvwq_IR78B6OkLOmRQYFbqtq-UXcOWfhQzN2yQc3PkgAIYgxHMnz4abW_PWEOvMs4whTE-yQb6GlK15W1qWd2uZNrvq0fRn2xZg4mvWGRoeZ59A4rxMdrsv29KR1hGc141M3bZ0_iOBxxBjgMnwJfK2zLMRKXAOLgv-_HV5ck sJtvHX-ZdsVIMbeB22VsWMnlqCnSHI_kEB8NG1v-HW3SvX7MnnSxNNqwK_UC3nxV7dRyyF86y5V1mbrYFXcERV6Mb5hNMmX0qlvvYnV0pYp_bQ";
string xoauthKey = OAuth2.GetXOAuthKeyStatic(userEmail, _token);
try
{
Imap imp = new Imap();
// In the log, you can find the actual search queries sent to the server.
//imp.Log.Filename = "C:\\Temp\\log.txt";
//imp.Log.Enabled = true;
//imp.Log.Clear();
//imp.Connect("imap.gmail.com", 993);
//imp.Login(userEmail, xoauthKey, AuthenticationMethods.SaslOAuth2, AuthenticationOptions.None, null);
//imp.SelectFolder("INBOX");
//Console.WriteLine(imp.MessageCount.ToString() + " message(s) in INBOX");
//imp.Disconnect();
Smtp mailer = new Smtp();
mailer.SmtpServers.Add("smtp.gmail.com", userEmail, xoauthKey, AuthenticationMethods.SaslOAuth2);
// Logging is not necessary but useful for debugging.
mailer.Log.Enabled = true;
mailer.Log.Filename = @"C:\Temp\log.txt";
mailer.Log.HidePasswords = false;
mailer.Log.Clear();
Console.WriteLine(mailer.IsSslConnection);
//mailer.From.Email = userEmail + " <" + userEmail + ">"; // + " <" + userEmail + ">"; //+ "<" + model.FromEmail + ">"
var _from = userEmail;
var _to = userEmail;
//Console.WriteLine(mailer.StartTls());
mailer.From.Email = userEmail;
//mailer.From.DisplayName = "<Dinesh Bhai>";
mailer.To.Add("***@gmail.com");
//mailer.Cc.Add(_from);
mailer.Subject = "empty email to myself";
mailer.BodyHtmlText = "Hello World !!!";
// For async/await version, see GoogleOAuthWinForms sample.
mailer.Send();
Console.WriteLine("E-mail sent");
}
catch (Exception ex)
{
Console.WriteLine("ERROR " + ex.Message);
throw;
}
Console.WriteLine();
Console.WriteLine("Press any key to exit.");
Console.WriteLine();
Console.WriteLine("To try other samples in the project, change startup object in project properties in Visual Studio.");
Console.WriteLine();
Console.ReadKey();
}
|
Back to Top |
|
|
Igor AfterLogic Support
![AfterLogic Support](forum_images/5_star_rating.gif)
Joined: 24 June 2008 Location: United States
Online Status: Offline Posts: 6082
|
Posted: 27 July 2020 at 5:54am | IP Logged
|
|
|
Have responded to this in HelpDesk. Thanks.
--
Regards,
Igor, Afterlogic Support
|
Back to Top |
|
|