Clear Screenshot of the code 这是发送电子邮件的代码,我真的不知道为什么当我将其用作移动应用程序时却不发送电子邮件
receiverEmail = inputEmail.text;
MailMessage mail = new MailMessage();
mail.From = new MailAddress(senderEmail);
mail.To.Add(receiverEmail);
mail.Subject = subject;
mail.Body = body;
SmtpClient smtpServer = new SmtpClient(server);
smtpServer.Port = 587;
smtpServer.Credentials = new NetworkCredential(senderEmail, senderPassword) as ICredentialsByHost;
smtpServer.EnableSsl = true;
ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors){
return true;
};
try
{
smtpServer.Send(mail);
emailStatus.GetComponentInChildren<Text>().text = "Email Sent !!";
}
catch (SmtpException error)
{
Debug.Log (error.StatusCode);
Debug.Log (error.Message);
emailStatus.GetComponentInChildren<Text>().text = "Email Not Sent \n" +error.Message+ "\n Error Number : "+ error.StatusCode;
}
答案 0 :(得分:0)
感谢@bugfinder,它确实是.net,我将我的版本从2.0子集更改为2.0,并且可以正常工作