admin管理员组文章数量:1434234
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 badge1 Answer
Reset to default 0It'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.
本文标签: cExchange Server Timout issue in Net Mail KitStack Overflow
版权声明:本文标题:c# - Exchange Server Timout issue in .Net Mail Kit - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745616344a2666425.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论