Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
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:
 
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 12-May-13 3:40am
AmrDeif651
Comments
ThePhantomUpvoter at 12-May-13 8:46am
   
Not every SMTP server uses the default port 25.
AmrDeif at 12-May-13 8:56am
   
so what should i do???
AmrDeif at 13-May-13 8:14am
   
Someone tell me what to do PLZ!!!!!

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

The Yahoo SMTP port is 465, not 25.
 
You also need EnableSsl set to true on the SmtpClient object.
  Permalink  
Comments
AmrDeif at 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 at 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.
AmrDeif at 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 at 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
0 OriginalGriff 274
1 Shweta N Mishra 216
2 PIEBALDconsult 210
3 Sergey Alexandrovich Kryukov 185
4 BillWoodruff 174
0 OriginalGriff 7,630
1 Sergey Alexandrovich Kryukov 7,022
2 DamithSL 5,586
3 Manas Bhardwaj 4,946
4 Maciej Los 4,525


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 12 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100