c# - Exchange Server Timout issue in .Net Mail Kit - Stack Overflow

Mail Kit package connect method throw operation timeout exception but EASendMail package send email suc

Mail Kit package connect method throw operation timeout exception but EASendMail package send email successfully with same properties in .Net app. You can see written c# code under below.

var host = "mailpany";
var port = 25;
var userName = "username";
var domain = "domain";
var password = "password";
var senderEmail = "[email protected]";
var senderName = "Sender Name";

MailKit:

var message = new MimeMessage();
message.From.Add(new MailboxAddress("", senderEmail));
message.To.Add(new MailboxAddress("","[email protected]"));
message.Subject = "test email";
MailKit.Net.Smtp.SmtpClient smtp = new MailKit.Net.Smtp.SmtpClient();
BodyBuilder body = new BodyBuilder();
smtp.ServerCertificateValidationCallback =
(s, certificate, chain, sslPolicyErrors) => true;
smtp.Connect(host,port,SecureSocketOptions.Auto); 
smtp.Authenticate(userName, password);
smtp.Send(message);

EASendMail

 SmtpMail oMail = new SmtpMail("TryIt");
 oMail.From = senderEmail;
 oMail.To = "[email protected]";
 oMail.Subject = "test email for test";
 oMail.TextBody = "testBody";
 SmtpServer oServer = new SmtpServer(host,port);
 oServer.User = userName;
 oServer.Password = password;
 oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;
 oServer.Protocol = ServerProtocol.ExchangeEWS;
 EASendMail.SmtpClient oSmtp = new EASendMail.SmtpClient();
 oSmtp.SendMail(oServer, oMail);

Any idea?

I expected email sent with Mail kit. In additional I tried send email with System.Net.Mail but its give timeout exception again.

Mail Kit package connect method throw operation timeout exception but EASendMail package send email successfully with same properties in .Net app. You can see written c# code under below.

var host = "mailpany";
var port = 25;
var userName = "username";
var domain = "domain";
var password = "password";
var senderEmail = "[email protected]";
var senderName = "Sender Name";

MailKit:

var message = new MimeMessage();
message.From.Add(new MailboxAddress("", senderEmail));
message.To.Add(new MailboxAddress("","[email protected]"));
message.Subject = "test email";
MailKit.Net.Smtp.SmtpClient smtp = new MailKit.Net.Smtp.SmtpClient();
BodyBuilder body = new BodyBuilder();
smtp.ServerCertificateValidationCallback =
(s, certificate, chain, sslPolicyErrors) => true;
smtp.Connect(host,port,SecureSocketOptions.Auto); 
smtp.Authenticate(userName, password);
smtp.Send(message);

EASendMail

 SmtpMail oMail = new SmtpMail("TryIt");
 oMail.From = senderEmail;
 oMail.To = "[email protected]";
 oMail.Subject = "test email for test";
 oMail.TextBody = "testBody";
 SmtpServer oServer = new SmtpServer(host,port);
 oServer.User = userName;
 oServer.Password = password;
 oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;
 oServer.Protocol = ServerProtocol.ExchangeEWS;
 EASendMail.SmtpClient oSmtp = new EASendMail.SmtpClient();
 oSmtp.SendMail(oServer, oMail);

Any idea?

I expected email sent with Mail kit. In additional I tried send email with System.Net.Mail but its give timeout exception again.

Share Improve this question asked Nov 18, 2024 at 13:03 mertkmertk 31 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

It's failing for MailKit and System.Net.Mail because you are using the SMTP protocol for those.

It works with EASendMail because you are using the EWS protocol instead of SMTP:

oServer.Protocol = ServerProtocol.ExchangeEWS;

This suggests that the SMTP protocol on your Exchange server is disabled.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745616344a4636260.html

相关推荐

  • c# - Exchange Server Timout issue in .Net Mail Kit - Stack Overflow

    Mail Kit package connect method throw operation timeout exception but EASendMail package send email suc

    7小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信