Search The ForumSearch   RegisterRegister  LoginLogin

MailBee.NET SMTP

 AfterLogic Forum : MailBee.NET SMTP
Subject Topic: Send mail via Gmail Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
milicevic
Newbie
Newbie


Joined: 16 October 2006
Location: Italy
Online Status: Offline
Posts: 4
Posted: 16 October 2006 at 8:24am | IP Logged Quote milicevic

Hello,

I am trying trial release of MailBeeNetSMTP, and facing problem when trying to send mail via GMail smtp service (smtp.gmail.com).

PLease find bellow code snippet and extract from log file I got.
Code:

Smtp.LicenseKey="xxxxxxxxx";
                
// Create SMTP object
smtp = new Smtp();

                      
                      smtp.Log.Enabled = true;
smtp.Log.Filename =@"C:\smtp_log.txt";
smtp.Log.Clear();

SmtpServer server = new SmtpServer();
server.Name = "smtp.gmail.com";
server.Port = 587;
server.AccountName =  "info@jahorina.info";     server.Pa ssword =  "xxx";           
          
smtp.SmtpServers.Add(server);
smtp.Connect();
smtp.Hello();
smtp.StartTls();
smtp.Hello();
smtp.Login();

// Set body  contents        &nbs p;         &nbs p; msgMailBee.BodyHtmlText  =  msg;         &n bsp;         &n bsp;smtp.Message = msgMailBee;

// Set e-mail  headers          ;      msgMailBee.From.Email  =  "info@jahorina.info";     msgMailBe e.From.DisplayName = "Predrag Milicevic";


          
// Try to send e-mail
smtp.Send();                      smtp.Disconnect();


Exception occurs on "smtp.Send();"

End this is the log file content
Quote:

[12:52:49.06] [INFO] Assembly version: 2.0.0.6.
[12:52:49.07] [INFO] Will resolve host "smtp.gmail.com".
[12:52:49.09] [INFO] Host "smtp.gmail.com" resolved to IP address(es) 66.249.93.109, 66.249.93.111.
[12:52:49.09] [INFO] Will connect to host "smtp.gmail.com" on port 587.
[12:52:49.15] [INFO] Socket connected to IP address 66.249.93.109 on port 587.
[12:52:49.21] [RECV] 220 mx.google.com ESMTP 27sm1702642ugp\r\n
[12:52:49.23] [INFO] Connected to mail service at host "smtp.gmail.com" on port 587 and ready.
[12:52:49.87] [INFO] Will send Hello command (HELO or EHLO).
[12:52:49.87] [SEND] EHLO UNLB-WS399\r\n
[12:52:49.93] [RECV] 250-mx.google.com at your service, [85.159.201.22]\r\n250-SIZE 20971520\r\n250-8BITMIME\r\n250-STARTTLS\r\n250 ENHANCEDSTATUSCODES\r\n
[12:52:49.93] [INFO] SMTP Hello completed.
[12:52:50.98] [INFO] Notify server that we are ready to start TLS/SSL negotiation.
[12:52:50.98] [SEND] STARTTLS\r\n
[12:52:51.04] [RECV] 220 2.0.0 Ready to start TLS\r\n
[12:52:51.04] [INFO] Start TLS/SSL negotiation sequence.
[12:52:51.21] [INFO] TLS/SSL negotiation completed.
[12:52:52.35] [INFO] Will send Hello command (HELO or EHLO).
[12:52:52.35] [SEND] EHLO UNLB-WS399\r\n
[12:52:52.43] [RECV] 250-mx.google.com at your service, [85.159.201.22]\r\n250-SIZE 20971520\r\n250-8BITMIME\r\n250-AUTH LOGIN PLAIN\r\n250 ENHANCEDSTATUSCODES\r\n
[12:52:52.43] [INFO] SMTP Hello completed.
[12:53:17.54] [INFO] Will send mail message to SMTP server "smtp.gmail.com".
[12:53:17.60] [INFO] Will submit sender and recipients.
[12:53:17.60] [SEND] MAIL FROM:<info@jahorina.info>\r\n
[12:53:17.67] [RECV] 530 5.5.1 Authentication Required 27sm1702642ugp\r\n
[12:53:17.70] [INFO] Error: The server rejected the specified sender email address. The server responded: 530 5.5.1 Authentication Required 27sm1702642ugp.
[12:53:17.70] [INFO] Will reset SMTP session.
[12:53:17.70] [SEND] RSET\r\n
[12:53:17.76] [RECV] 250 2.1.0 Flushed 27sm1702642ugp\r\n
[12:53:17.78] [INFO] SMTP session was reset.
Back to Top View milicevic's Profile Search for other posts by milicevic
 
milicevic
Newbie
Newbie


Joined: 16 October 2006
Location: Italy
Online Status: Offline
Posts: 4
Posted: 16 October 2006 at 9:52am | IP Logged Quote milicevic

Addition

After changing some properties to values:
Code:

server.SslProtocol=MailBee.Security.SecurityProtocol.Auto;
server.AuthMethods=AuthenticationMethods.Auto;
server.SslMode=MailBee.Security.SslStartupMode.UseStartTls;


and using simple smtp.Send(); message arrives at destination, but exception is raised:

"Socket connection was aborted by remote host"
when method "Send()" is called?

Regards,
Back to Top View milicevic's Profile Search for other posts by milicevic
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 16 October 2006 at 12:40pm | IP Logged Quote Andrew

Could you please provide us with the new log (when authentication is enabled)?
Back to Top View Andrew's Profile Search for other posts by Andrew
 
milicevic
Newbie
Newbie


Joined: 16 October 2006
Location: Italy
Online Status: Offline
Posts: 4
Posted: 17 October 2006 at 2:24am | IP Logged Quote milicevic

Here it is:

Please note that same kind of exception is raised by your SSL code example.
Quote:

[08:20:31.32] [INFO] Assembly version: 2.0.0.6.
[08:20:31.32] [INFO] Will send mail message.
[08:20:31.35] [INFO] Will send mail message to SMTP server "smtp.gmail.com".
[08:20:31.35] [INFO] Will resolve host "smtp.gmail.com".
[08:20:31.37] [INFO] Host "smtp.gmail.com" resolved to IP address(es) 66.249.93.109, 66.249.93.111.
[08:20:31.37] [INFO] Will connect to host "smtp.gmail.com" on port 587.
[08:20:31.43] [INFO] Socket connected to IP address 66.249.93.109 on port 587.
[08:20:31.53] [RECV] 220 mx.google.com ESMTP 55sm2486010ugq\r\n
[08:20:31.53] [INFO] Connected to mail service at host "smtp.gmail.com" on port 587 and ready.
[08:20:31.53] [INFO] Will send Hello command (HELO or EHLO).
[08:20:31.54] [SEND] EHLO jahorina.info\r\n
[08:20:31.60] [RECV] 250-mx.google.com at your service, [85.159.201.23]\r\n250-SIZE 20971520\r\n250-8BITMIME\r\n250-STARTTLS\r\n250 ENHANCEDSTATUSCODES\r\n
[08:20:31.60] [INFO] SMTP Hello completed.
[08:20:31.60] [INFO] Notify server that we are ready to start TLS/SSL negotiation.
[08:20:31.62] [SEND] STARTTLS\r\n
[08:20:31.68] [RECV] 220 2.0.0 Ready to start TLS\r\n
[08:20:31.68] [INFO] Start TLS/SSL negotiation sequence.
[08:20:31.82] [INFO] TLS/SSL negotiation completed.
[08:20:31.84] [INFO] Will send Hello command (HELO or EHLO).
[08:20:31.84] [SEND] EHLO jahorina.info\r\n
[08:20:31.90] [RECV] 250-mx.google.com at your service, [85.159.201.23]\r\n250-SIZE 20971520\r\n250-8BITMIME\r\n250-AUTH LOGIN PLAIN\r\n250 ENHANCEDSTATUSCODES\r\n
[08:20:31.92] [INFO] SMTP Hello completed.
[08:20:31.92] [INFO] Will login as "info@jahorina.info".
[08:20:31.92] [INFO] Will try SASL LOGIN authentication method.
[08:20:31.92] [SEND] AUTH LOGIN\r\n
[08:20:31.98] [RECV] 334 VXNlcm5hbWU6\r\n
[08:20:32.00] [SEND] ********\r\n
[08:20:32.06] [RECV] 334 UGFzc3dvcmQ6\r\n
[08:20:32.06] [SEND] ********\r\n
[08:20:32.54] [RECV] 235 2.7.0 Accepted\r\n
[08:20:32.62] [INFO] Logged in as "info@jahorina.info".
[08:20:32.62] [INFO] Will submit sender and recipients.
[08:20:32.64] [SEND] MAIL FROM:<info@jahorina.info>\r\n
[08:20:32.70] [RECV] 250 2.1.0 OK\r\n
[08:20:32.70] [SEND] RCPT TO:<predragmilicevic@yahoo.com>\r\n
[08:20:32.76] [RECV] 250 2.1.5 OK\r\n
[08:20:32.78] [INFO] Sender and recipients accepted by SMTP server. Will send message data now.
[08:20:32.78] [SEND] DATA\r\n
[08:20:34.17] [RECV] 354 Go ahead\r\n
[08:20:34.18] [SEND] [Data chunk of 520 bytes sent.]
[08:20:34.18] [SEND] \r\n.\r\n
[08:20:34.64] [RECV] 250 2.0.0 OK 1161066033 55sm2486010ugq\r\n
[08:20:34.65] [INFO] Message successfully submitted to SMTP server.
[08:20:34.67] [SEND] QUIT\r\n
[08:20:34.76] [INFO] Will disconnect from host "smtp.gmail.com".
[08:20:34.78] [INFO] Disconnected from host "smtp.gmail.com".
[08:20:34.78] [INFO] Error: Socket connection was aborted by remote host.
Back to Top View milicevic's Profile Search for other posts by milicevic
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 17 October 2006 at 8:50am | IP Logged Quote Andrew

Gmail SMTP behaves a bit incorrectly during closing connection. It suddenly closes connection instead of sending the appropriate message.

To avoid this problem, you can catch MailBeeAbortedByRemoteHostException during disconnection, or even better, don't use Connect/Disconnect methods explicitly. Simply comment the following lines in your code:
Code:
smtp.Connect();
smtp.Hello();
smtp.StartTls();
smtp.Hello();
smtp.Login();

and

smtp.Disconnect();


In such case, Send method performs connection and disconnection automatically and catches exceptions during disconnection. All other mail clients ignore suddenly closing connections by Gmail, MailBee.NET Objects can do this too if Connect/Disconnect methods aren't called explicitly.


Best regards,
Andrew
Back to Top View Andrew's Profile Search for other posts by Andrew
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide