I am sending a mail From my App. When I tried the code below, it sends the mail from unity Editor. But when I build and tested my app on an ipad, the mail is not sent from my App.
public void Start() {
using (var mail = new MailMessage {
From = new MailAddress(sender),
Subject = "test subject",
Body = "Hello there!"})
{
mail.To.Add(receiver);
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; };
smtpServer.Send(mail);
}
}
It works only when using the Editor. Not in my App (iPad).
What's wrong in my code? I have also enabled the "Allow secure less apps" in my Gmail account.