Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey Guys,

i am trying to send email using asp.net and i got this SMTPException:

Failure sending mail.
{"Unable to read data from the transport connection: net_io_connectionclosed."}

and Her is My Code:

C#
try
        {
            //YAHOO SMTP Host (smtp.mail.yahoo.com)
            //GMAIL SMTP Host (smtp.gmail.com)
            //WINDOWS LIVE SMTP HOST (smtp.live.com)
            SmtpClient mySmtpClient = new SmtpClient("smtp.mail.yahoo.com", 25);

            // set smtp-client with basicAuthentication
            mySmtpClient.UseDefaultCredentials = false;
            System.Net.NetworkCredential basicAuthenticationInfo = new
               System.Net.NetworkCredential("myEmail", "myPassword");
            mySmtpClient.Credentials = basicAuthenticationInfo;

            // add from,to mailaddresses
            MailAddress from = new MailAddress("From_Email", "Title");
            MailAddress to = new MailAddress("To_Email", "Test Email");
            MailMessage myMail = new System.Net.Mail.MailMessage(from, to);

            // set subject and encoding
            myMail.Subject = Email_Subject;
            myMail.SubjectEncoding = System.Text.Encoding.UTF8;

            // set body-message and encoding
            myMail.Body = Email_Body;
            myMail.BodyEncoding = System.Text.Encoding.UTF8;
            // text or html
            myMail.IsBodyHtml = true;

            mySmtpClient.Send(myMail);
            return true;
        }
        catch (SmtpException ex)
        {
            return false;
        }
        catch (Exception ex)
        {
            return false;
        }


Any Ideas????????????
Posted
Comments
[no name] 12-May-13 8:46am    
Not every SMTP server uses the default port 25.
_ProgProg_ 12-May-13 8:56am    
so what should i do???
_ProgProg_ 13-May-13 8:14am    
Someone tell me what to do PLZ!!!!!

1 solution

The Yahoo SMTP port is 465, not 25.

You also need EnableSsl set to true on the SmtpClient object.
 
Share this answer
 
Comments
_ProgProg_ 13-May-13 5:19am    
Thanks Dave Kreskowiak for Your Reply
I've tried this but it didn't work
i've the same error
Unable to read data from the transport connection: net_io_connectionclosed
Dave Kreskowiak 13-May-13 12:54pm    
The SmtpClient only supports one of the two SSL authentication methods available. Try disabling SSL and using port 587 instead.

Oh, and I'm seeing that you might need a Yahoo Plus account to use the SMTP servers.
_ProgProg_ 15-May-13 8:21am    
the application sends emails and the email i send from (sender) is not valid after a number of right sending???
why is this?
does yahoo suspend email that sends more emails???
Dave Kreskowiak 15-May-13 8:24am    
I have no idea what you mean by "is not vlaid after a number of right sending". That makes no sense.

But, if you mean you can no longer send emails, yes, you cannot use Yahoo for bulk mail. I don't know what the limit is per day. You will have to contact Yahoo Support for that information or whatever service they offer for such, if any.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900