Search Unity

Send Mail is Not working in Android 7.0

Discussion in 'Scripting' started by Alexander21, Jul 3, 2019.

  1. Alexander21

    Alexander21

    Joined:
    Dec 14, 2015
    Posts:
    220
    Hi All

    I am using Unity 2018.3.7. In My project i am sending mail from my APK. I am using the below code for send mail.
    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. }
    The mail is send from editor, Android Version 8.0,9.0 and ipad. But the mail is not send from android 7 versions

    Samsung j3 prime, MI ..

    So what i have to send mail from unity android 7.0. Is there any default settings.

    I have enabled less secure apps, intenet access = require, .net 4.0 stripping level disabled..

    NOTE: IT IS WORKING IN ANDROID 8.0. ANDROID 7.0 MAIL IS NOT SENDING FROM IT.
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    4,760
    Run logcat or get a runtime console to see if any errors are being displayed (free ones are on the asset store).
     
  3. Alexander21

    Alexander21

    Joined:
    Dec 14, 2015
    Posts:
    220
    @brathnan thanks for your reply . I have tried your method. Actually the problem is the mail is send in Android 7.0 when WI FI is connected.

    When it is working on mobile network. the mail is not send from android 7,0 mobiles.

    Did any thing firewall or any other apps thwarted from sending mobile from mobile network?

    so can any one have any suggestions for this problem.

    Thanks in advence