Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
   MailMessage mm = new MailMessage();
        mm.To.Add(receiver);
        mm.Body = body;
        mm.From = new MailAddress("feedback@delwyntech.com");
        mm.Subject = sub;
        try
        {
            Ping ping = new Ping();
            PingReply pingreply = ping.Send("gmail.com");
            string x = pingreply.Status.ToString();
            if (x == "Success")
            {
                SmtpClient smtp = new SmtpClient();
                try
                {
                    smtp.Host = "smtpout.secureserver.net";                    
                    smtp.EnableSsl = true; //Depending on server SSL Settings true/false
                    System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential();
                    NetworkCred.UserName = "feedback@gowyn.com";
                    NetworkCred.Password = "password"; 
                    smtp.Credentials = NetworkCred;
                    smtp.UseDefaultCredentials = true;
                    smtp.Port = 465;//Specify your port No;
                    smtp.Send(mm);
 

Exception Detail:
 
System.Net.Mail.SmtpException was caught
  Message=Failure sending mail.
  Source=System
  StackTrace:
       at System.Net.Mail.SmtpClient.Send(MailMessage message)
       at db_fn.sendemail(String body, String sub, String sender, String receiver) in c:\Users\Administrator\Dropbox\crm\App_Code\db_fn.cs:line 225
  InnerException: System.IO.IOException
       Message=Unable to read data from the transport connection: net_io_connectionclosed.
       Source=System
       StackTrace:
            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.SmtpConnection.GetConnection(ServicePoint servicePoint)
            at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)
            at System.Net.Mail.SmtpClient.GetConnection()
            at System.Net.Mail.SmtpClient.Send(MailMessage message)
       InnerException: 
 

Plz help me out..!!!!!!
Posted 9-Mar-13 4:52am
Edited 9-Mar-13 5:02am
v2
Comments
ThePhantomUpvoter at 9-Mar-13 9:57am
   
Please post the real error message that you are getting, along with the stack trace and identify the line of code that is getting the error. Unless you are really getting an SQL error, then post that code instead.
Sanjeev236 at 9-Mar-13 10:02am
   
thnaks.. question modified..!!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

mike meinz is correct the UseDefaultCredentials should be false. Aside from that I would check the port as well the most commonly used ports are 10, 25, 110 465, and 587. I have personally had more luck with port 587.
  Permalink  
Comments
Sanjeev236 at 10-Mar-13 0:07am
   
changes defaultcredentials to false..but still problem persists.
tried other ports too... and for further info,same port 465 is working great in outlook.!!!!
Mike Meinz at 10-Mar-13 10:14am
   
Sorry. The only other thing I can think of is maybe the login id NetworkCred.UserName should just be the username part of the email address and not include the @domainname part.
charles henington at 11-Mar-13 6:53am
   
not sure but i know in most cases the @domainname part must be included.
also ive noticed that you call the smtp.UseDefaultCredentials = false; after you specify the NetworkCredentials try calling the UseDefaultCredentials = false before you change the Credentials when i sent a message with gmail it must be done in this manner or an error will be thrown
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

private void button1_Click(object sender, EventArgs e)
        {
            string reciever = "recipent";
            string subject = "subject";
            string body = "body";
            try
            {
                using (MailMessage message = new MailMessage("feedback@delwyntech.com", reciever)
                {
                    Subject = subject,
                    Body = body
                })
                {
                    using (SmtpClient client = new SmtpClient("smtpout.secureserver.net", 465)
                    {
                        EnableSsl = true,
                        UseDefaultCredentials = false,
                        Credentials = new NetworkCredential("feedback@gowyn.com", "password")
                    })
                    {
                        client.Send(message);
                    }
                }
            }
            catch (Exception mailException)
            {
                // if an exception is thrown display exception message for debug  purposes
                MessageBox.Show(mailException.Message);
            }
        }
  Permalink  
Comments
Sanjeev236 at 12-Mar-13 5:16am
   
System.Net.Mail.SmtpException was caught
Message=Failure sending mail.
Source=System
StackTrace:
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at Sent_mail.Button2_Click(Object sender, EventArgs e) in c:\Documents and Settings\admin\My Documents\Dropbox\crm\Sent_mail.aspx.cs:line 69
InnerException: System.IO.IOException
Message=Unable to read data from the transport connection: net_io_connectionclosed.
Source=System
StackTrace:
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.SmtpConnection.GetConnection(ServicePoint servicePoint)
at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
InnerException:
 

Sorry Charles No Luck... :( Still i appreciate your work heartly.
charles henington at 12-Mar-13 13:26pm
   
try it on port 80 and alternating EnableSsl i know that when using yahoo EnableSsl must be set to false perhaps thats the case here. also check out http://support.godaddy.com/groups/email/forum/topic/cant-send-email-using-smtpout-secureserver-net/.
theres an interesting fix with the server address perhaps that may be of assistance to you
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I found these two documentation items. Maybe one or both of these will help you solve this problem.
 
The documentation for SmtpClient.EnableSsl Property[^] says:
If the EnableSsl property is set to true, and the SMTP mail server does not advertise STARTTLS in the response to the EHLO command, then a call to the Send or SendAsync methods will throw an SmtpException.
 
The documentation for SmtpClient.UseDefaultCredentials Property[^] says:
Set this property to true when this SmtpClient object should, if requested by the server, authenticate using the default credentials of the currently logged on user. For client applications, this is the desired behavior in most scenarios.
The tag for your question says ASP.NET so it is not a Client Application. Perhaps UseDefaultCredentials should be False since you are supplying the credentials.
  Permalink  
Comments
Sanjeev236 at 10-Mar-13 0:06am
   
changes defaultcredentials to false..but still problem persists.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

SmtpClient ss = new SmtpClient();
               ss.Host = "relay-hosting.secureserver.net";
                ss.Port = 25;
                ss.Timeout = 10000;
                ss.DeliveryMethod = SmtpDeliveryMethod.Network;
                ss.UseDefaultCredentials = false;
                ss.Credentials = new NetworkCredential("your_full_emailAddress", "YourPassword", "your_Domain");
                ss.EnableSsl = false;
 
                MailMessage mailMsg = new MailMessage("your_full_emailAddress", "demo@gmail.com", "subject here", "my body");
                mailMsg.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
                ss.Send(mailMsg);
 
                Response.Write("Mail Sent");
  Permalink  

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

  Print Answers RSS
0 Mathew Soji 334
1 Maciej Los 295
2 BillWoodruff 290
3 Afzaal Ahmad Zeeshan 257
4 DamithSL 225
0 OriginalGriff 6,369
1 Sergey Alexandrovich Kryukov 5,973
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 4,045


Advertise | Privacy | Mobile
Web04 | 2.8.1411019.1 | Last Updated 20 Apr 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