Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by JohnLadder · Dec 09, 2016 at 02:26 PM · iosshadersemail

How to send email using smtp to IOS?

I've tried everything I've seen that is somehow related to my question (in this forum) and I can't manage to send an email in an IOS device. It works in the Unity Editor and on Android devices.

Below is my code->

public void Send() { MailMessage mail = new MailMessage();

     mail.From = new MailAddress(senderEmail);
     mail.To.Add(myEmail);
     mail.Subject = "Test Mail";
     mail.Body = "This is for testing SMTP mail from GMAIL";
     
     SmtpClient smtpServer = new SmtpClient("smtp.gmail.com");
     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");

 }

Why is it not working in IOS?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image jpatinop80 · May 26, 2017 at 04:58 PM 0
Share

Did you find the way to put it work?

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by catiejojo · Oct 29, 2018 at 01:25 PM

Apologies for poking an old thread, but in case anyone gets here from search, the mono scripting backend isn't supported from iOS 11 and up. You should still set the API to .NET 2.0 (not subset), and add a link.xml file to your Assets folder with the following text:

 <linker>
 <assembly fullname="System">
 <type fullname="System.Net.Configuration.MailSettingsSectionGroup" preserve="all"/>
 <type fullname="System.Net.Configuration.SmtpSection" preserve="all"/>
 <type fullname="System.Net.Configuration.SmtpNetworkElement" preserve="all"/>
 <type fullname="System.Net.Configuration.SmtpSpecifiedPickupDirectoryElement" preserve="all"/>
 </assembly>
 </linker>

This is because the IL2CPP scripting backend strips this out of the build, so you need to manually link it. Hope this helps!

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AlexKayz · Dec 03, 2018 at 11:57 AM 0
Share

Hello @catiejojo!

So all I have to do is create a new text file, change its extension to .xml, copy paste the text inside it and the place it in the assets folder?

avatar image catiejojo AlexKayz · Dec 03, 2018 at 12:00 PM 1
Share

You need to create a new xml file (.xml), not a text file (.txt), but yes then it should work!

avatar image Koyemsi catiejojo · May 22, 2019 at 12:38 PM 0
Share

Hi. I made a small iOS app in which I desperately try to send mail via S$$anonymous$$TP (works fine in Unity editor). I tried your solution. But when I build in Xcode, I obtain errors and the build fails ; cannot install and run on my iPhone. Seems like it doesn't want of the API change. I'm using Unity 2018.3 and Xcode 10.1. Thanx for any help

avatar image
0

Answer by Devin_Stewart · Jun 16, 2017 at 10:48 PM

Hey Naharadir,

Not sure if you're still looking for an answer to this, but I'll post my solution here just in case.

I am having success with SMTP emails on IOS by changing the Scripting backend and Api compatibility level options in Edit --> Project Settings --> Player --> Settings for IOS tab --> Other Settings.

Change the scripting backend to Mono2x.

And Change the Api Compatibilty Level to .NET 2.0.

Configuration for scripting backend and Api compatibility level

Hope that helps!

-Devin Stewart


settings.png (4.0 kB)
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Material with Custom Shader in AssetBundles 0 Answers

Why is shader behavior different between Android and iOS? 1 Answer

Changing mesh shader not working iOS 0 Answers

Can't send email from ios device when email body contains arabic characters! 2 Answers

Unity on iOS - Specular Shader 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges