- Home /
Can't access to gmail using the build
Hi everyone. I need to send an email using the game and I've this issue.
When I try the game in the editor it sends the mail correctly.
When I build the game and I try to send the email using the .exe file it raises this:
Platform assembly: D:\DropBox Storage\Dropbox\Project\Exec\Exec PC\Updated version\OSR_Data\Managed\Mono.Security.dll (this message is harmless) SmtpException: 530-5.5.1 Authentication Required. Learn more at
530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 l10sm4506847wif.20 - gsmtp
at System.Net.Mail.SmtpClient.SendCore (System.Net.Mail.MailMessage message) [0x00000] in :0
at System.Net.Mail.SmtpClient.SendInternal (System.Net.Mail.MailMessage message) [0x00000] in :0
at System.Net.Mail.SmtpClient.Send (System.Net.Mail.MailMessage message) [0x00000] in :0
The Code I'm using is the following:
static public void mono_gmail (string receiver, string subject, string body)
{
MailMessage mail = new MailMessage();
//mail content here
mail.From = new MailAddress(sampleemail@gmail.com, "Name");
mail.To.Add(receiver);
mail.Subject = subject;
mail.Body = body;
//attaching a file here
System.Net.Mail.Attachment data;
data = new System.Net.Mail.Attachment("filePathhere");
mail.Attachments.Add(data);
SmtpClient smtpServer = new SmtpClient(senderSmtp);
smtpServer.Port = 587;
smtpServer.Credentials = new System.Net.NetworkCredential(senderEmail, senderPassword) as ICredentialsByHost;
smtpServer.EnableSsl = true;
ServicePointManager.ServerCertificateValidationCallback =
delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{ return true; };
smtpServer.Send(mail);
Debug.Log("success");
}
Answer by Jack-Mariani · Oct 06, 2014 at 07:29 AM
I just need to change Api Compatibility Level from ".NET 2.0 Subset" to ".NET 2.0".
You can find it in player settings (File->Build Settings...->Player Settings...->OtherSettings)
Found the solutions in these answers:
http://answers.unity3d.com/questions/378545/send-an-email-from-the-game.html http://answers.unity3d.com/questions/397992/sending-email-from-unity-works-in-editor-not-in-st.html
Answer by codemaker2015 · Dec 21, 2021 at 02:52 PM
Ensure that you have changed Internet access from auto to require in Player settings --> other settings --> configuration
Use this reference to create application specified password.