System.Net.Mail.SmtpException: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/?p=BadCredentials p129-20020a1c2987000000b003974cb37a94sm3730780wmp.22 - gsmtp
it used to work
now we have:
is it possible to use any else email provider and I’d need some help in coding:
this is my used to work code:
using UnityEngine;
using System.Collections;
using System;
using System.Net;
using System.Net.Mail;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
public class EmailSend
{
static string myEmail = "****";
static string myPassword = "****";
public static void Send(string target, string body, ConnectionType conType)
{
try
{
string subject = "";
if (conType == ConnectionType.changePassword)
{
subject = "Confirm to Change Password";
body = "if you didn't want to change the password simply ignore this message\n" +
"else this is confirmation number: " + body;
}//if change email
else if (conType == ConnectionType.changeEmail)
{
subject = "Confirm to Change Email";
body = "if you didn't want to change the email simply ignore this message\n" +
"else this is confirmation number: " + body;
}//change confirmation
else if (conType == ConnectionType.changeConfirmation)
{
subject = "Confirm to confirmation to change email or password";
body = "if you didn't want to change confirmation of changing the password or email simply ignore this message\n" +
"else this is confirmation number: " + body;
}//register
else if (conType == ConnectionType.register)
{
subject = "Confirm registration on infinity elements forum";
body = "if you didn't want to register on infinity elements forum simply ignore this message\n" +
"else this is confirmation number: " + body;
}
MailMessage mail = new MailMessage();
mail.From = new MailAddress(myEmail);
mail.To.Add(target);
mail.Subject = subject;
mail.Body = body;
SmtpClient smtpClient = new SmtpClient("smtp.gmail.com");
smtpClient.Port = 587;
smtpClient.Credentials = new NetworkCredential(myEmail, myPassword) as ICredentialsByHost; // (ICredentialsByHost)CredentialCache.DefaultNetworkCredentials;
smtpClient.EnableSsl = true;
smtpClient.UseDefaultCredentials = false;
ServicePointManager.ServerCertificateValidationCallback =
delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{ return true; };
//smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.Send(mail);
Debug.Log("email sucsessly sended body: " + body);
}
catch (System.Exception e)
{
Debug.Log(e);
Debug.Log("failed sending body: " + body);
}
}
}