Search Unity

Send Mail is not working in Android 7.0

Discussion in 'Scripting' started by Alexander21, May 25, 2019.

  1. Alexander21

    Alexander21

    Joined:
    Dec 14, 2015
    Posts:
    302
    Hi All

    Have a Nice day...

    In My project i am sending mail through unity. Actually Mail is sending in pc and also in mobiles android version 8.0. But When i test my send mail option in Android 8.0 Samsung j3 prime.

    Mail is not send from that mobile. But It is very well working in other mobiles. This is my below code..

    Code (CSharp):
    1. public void Start() {
    2. using (var mail = new MailMessage {
    3. From = new MailAddress(sender),
    4. Subject = "test subject",
    5. Body = "Hello there!"
    6. }) {
    7. mail.To.Add(receiver);
    8. var smtpServer = new SmtpClient(smtpHost) {
    9. Port = 25,
    10. DeliveryMethod = SmtpDeliveryMethod.Network,
    11. EnableSsl = true,
    12. UseDefaultCredentials = false,
    13. Credentials = (ICredentialsByHost)new NetworkCredential(sender, smtpPassword)
    14. };
    15. ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
    16. smtpServer.Send(mail);
    17. }
    18. }
    19. }

    i am sending throuh gmail. It s working in all mobiles excep Android 8.0 Samsung j3 prime.

    What i have to do for that?