Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
My site has some functionality to send email to user some perspective. I have done this. My method can sending email successfully when i am running this application from Visual Studio or My local IIS 7 server (I Configured My PC). But the remote online web server can't send email. Please give me some tips how can i solve this issue. I have already gave lot of time to google but not found this solution. My code
 
const string fromAddress = "ejobsbdinfo@gmail.com";
const string fromPassword = "password";
string toAddress = account.Email;
string subject = "subject";
string body = "mail Body";
var smtp = new System.Net.Mail.SmtpClient();
{
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
smtp.Timeout = 20000;
}
smtp.Send(fromAddress, toAddress, subject, body);
 
give me some instruction how can i solve this problem.
Posted 27-Mar-13 21:15pm
Comments
Bernhard Hiller at 28-Mar-13 4:11am
   
what's the error message?
Member 9399759 at 28-Mar-13 4:32am
   
Thanks for reply , The exception is bellow....
 
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

using System.Net;
using System.Net.Mail;
public partial class RegistrationForm : System.Web.UI.Page
   {
    
       protected void Page_Load(object sender, EventArgs e)
       {
 
       }
 
protected void send mail(object sender, EventArgs e)
     {
NetworkCredential cred = new NetworkCredential(email Id, Password);
            MailMessage msg = new MailMessage();
            msg.To.Add(TextBox4.Text);
            msg.Subject = "Welcome To Website";
           
            msg.Body = "You Have Successfully Registered" ;
            msg.From = new MailAddress("welcome@gmail.com"); // Your Email Id
            SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
            SmtpClient client1 = new SmtpClient("smtp.mail.yahoo.com", 465);
            client.Credentials = cred;
            client.EnableSsl = true;
            client.Send(msg);
}

}
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 325
1 DamithSL 265
2 CPallini 235
3 Sergey Alexandrovich Kryukov 229
4 Maciej Los 190
0 OriginalGriff 5,455
1 DamithSL 4,422
2 Maciej Los 3,860
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,010


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 28 Mar 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