here is my code
for(int i = 0; i < number ; i++)
{
MailAddress to = new MailAddress(iMail.to);
MailAddress from = new MailAddress(iMail.from, iMail.displayName);
string body = iMail.body;
string subject = iMail.sub;
oMail = new MailMessage(from, to);
oMail.Subject = subject;
oMail.Body = body;
oMail.IsBodyHtml = true;
oMail.Priority = MailPriority.Normal;
oMail.Sender = from;
s = new SmtpClient(smtpServer);
if (s != null)
{
s.Send(oMail);
}
oMail.Dispose();
s = null;
}
this loops sends over 60,000 email. but my problem i am getting " failure sending mail" in some of the email some times 5000 and some time less then that rest of them gets delivered. and i have check all those error out email has valid email address. dont know what is the problem. i really need help in this.
Edit: This is my exception Trace
Error - Failure sending mail.; Inner Ex - System.IO.IOException: Unable to read data from the transport connection: net_io_connectionclosed. at System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[] buffer, Int32 offset, Int32 read, Boolean readLine) at System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine) at System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller) at System.Net.Mail.CheckCommand.Send(SmtpConnection conn, String& response) at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from) at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
Generally the Failure sending email error comes when debugged leads to the following error: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5. 1 Authentication Required in ASP.Net Application.
Check whether there is network access from CSO to the SMTP server. Check whether the firewall is blocking SMTP traffic to SMTP server or whether the ports are blocked. If the server settings and authentication settings are correct, check whether the firewall is blocking port 587 and 465 and SMTP traffic.
Well, the "failure sending e-mail" should hopefully have a bit more detail. But there are a few things that could cause this.
Regardless if it is one of these or another error, you will want to look at the exception and inner exception to get a bit more detail.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With