0

Login form

enter image description here

hi upon clicking the link label on the form an automated mail is sent to ONLY 1 specific email address Email subject : Reset password for [username] Email body : Please reset password for user [username]

NajiMakhoul
  • 1,623
  • 2
  • 16
  • 30

1 Answers1

1

Pls read till the end and you will surely be able to solve your problem.

using System.Net;
using System.Net.Mail;
using System.Net.Mime;

...
try
{

   SmtpClient mySmtpClient = new SmtpClient("my.smtp.exampleserver.net");

    // set smtp-client with basicAuthentication
    mySmtpClient.UseDefaultCredentials = false;
   System.Net.NetworkCredential basicAuthenticationInfo = new
      System.Net.NetworkCredential("youremailid", "youremailpassword");
   mySmtpClient.Credentials = basicAuthenticationInfo;
   mySmtpClient.EnableSsl = true;
   // add from,to mailaddresses
   MailAddress from = new MailAddress("youremailid@example.com", "TestFromName");
   MailAddress to = new MailAddress("toemailid@example.com", "TestToName");
   MailMessage myMail = new System.Net.Mail.MailMessage(from, to);

   // add ReplyTo
   MailAddress replyto = new MailAddress("reply@example.com");
   myMail.ReplyToList.Add(replyTo);

   // set subject and encoding
   myMail.Subject = "Reset password for [username]";

   // set body-message and encoding
   myMail.Body = "Please reset password for user [username]";

   mySmtpClient.Send(myMail);
}

catch (SmtpException ex)
{
  throw new ApplicationException
    ("SmtpException has occured: " + ex.Message);
}
catch (Exception ex)
{
   throw ex;
}

Google may block sign in attempts from some apps or devices that do not use modern security standards. Since these apps and devices are easier to break into, blocking them helps keep your account safer.

Therefore, you have to enable Less Secure Sign-In (or Less secure app access) in your google account.

After sign into google account, go to:

https://www.google.com/settings/security/lesssecureapps

or

https://myaccount.google.com/lesssecureapps

The above code is taken from @NajiMakhoul's link :) Sending E-Mail using C# while the rest info is taken from this link:SMTP Error C#

D J
  • 845
  • 1
  • 13
  • 27