Hi All
I am developing an OnBoarding App in unity, where I am sending a mail to the user’s email address, if he forgets the password.I want to check if the mail has been sent sucessfully or not. Is there any method to
know that for sure.In case if an email id does’nt exists, then would I detect a failure.
I am using this below code. For Sending mail
using (var mail = new MailMessage
{
From = new MailAddress(sender),
Subject = " Password " + PlayerPrefs.GetInt("PPI_Passcode"),
Body = "Password is " + PlayerPrefs.GetInt("PPI_Passcode")
})
try{
mail.To.Add(receiver);
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess;
}
catch (Exception ex){
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
Debug.Log("error");
}
Debug.Log("The Mail Delivered are "+mail.DeliveryNotificationOptions);
var smtpServer = new SmtpClient(smtpHost)
{
Port = 25,
DeliveryMethod = SmtpDeliveryMethod.Network,
EnableSsl = true,
UseDefaultCredentials = false,
Credentials = (ICredentialsByHost)new NetworkCredential(sender, smtpPassword)
};
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
try
{
smtpServer.Send(mail);
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess;
}
catch (Exception ex)
{
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
Debug.Log("ERROR ");
}
}
But Mail.DeliveryNotificationOptions is not working. I am using Gmail from Sending mail.
Catch Sometimes working. Some times not…So is there any way to find the mail has been reached the user or not.
Some times the user may give wrong id. So at the time i have to inform the id is wrong. Is there any way to do it?