Click here to Skip to main content
11,647,644 members (66,806 online)
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 20: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 jyo.net 500
1 F-ES Sitecore 370
2 OriginalGriff 322
3 DamithSL 315
4 CPallini 240
0 OriginalGriff 1,342
1 jyo.net 994
2 DamithSL 971
3 Sergey Alexandrovich Kryukov 873
4 CPallini 795


Advertise | Privacy | Mobile
Web01 | 2.8.150804.3 | Last Updated 28 Mar 2013
Copyright © CodeProject, 1999-2015
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