Send mail via System.Net.Mail.SmtpClient isn't working on Android, but on Windows
See original GitHub issueDescription
I’ve created a small sample trying to send an email using theSystem.Net.Mail.SmtpClient
. The sample is working on Windows, but not on Android. An Interop+AndroidCrypto+SslException
is thrown.
Steps to Reproduce
- Create a File > New .NET MAUI App
- Create a
System.Net.Mail.SmtpClient
and calling theSendMailAsync()
on Android - An
Interop+AndroidCrypto+SslException
is thrown - Run the same code on Windows and the email is sent
I’ve tried using an outlook.com
mail address with the smtp-mail.outlook.com
host.
See the following basic sample: MauiSendMailSample.zip
Version with bug
6.0.486 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android, I was not able test on other platforms
Affected platform versions
Android
Did you find any workaround?
No response
Relevant log output
{System.Net.Mail.SmtpException: Failure sending mail.
---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception.
---> Interop+AndroidCrypto+SslException: Exception of type 'Interop+AndroidCrypto+SslException' was thrown.
--- End of inner exception stack trace ---
at System.Net.Security.SslStream.<ForceAuthenticationAsync>d__175`1[[System.Net.Security.AsyncReadWriteAdapter, System.Net.Security, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext()
at System.Threading.Tasks.TaskToApm.End(IAsyncResult asyncResult)
at System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult asyncResult)
at System.Net.TlsStream.EndAuthenticateAsClient(IAsyncResult asyncResult)
at System.Net.Mail.SmtpConnection.ConnectAndHandshakeAsyncResult.TlsStreamAuthenticateCallback(IAsyncResult result)
--- End of stack trace from previous location ---
at System.Net.Mail.SmtpConnection.ConnectAndHandshakeAsyncResult.End(IAsyncResult result)
at System.Net.Mail.SmtpConnection.EndGetConnection(IAsyncResult result)
at System.Net.Mail.SmtpTransport.EndGetConnection(IAsyncResult result)
at System.Net.Mail.SmtpClient.ConnectCallback(IAsyncResult result)
--- End of inner exception stack trace ---
at MauiSendMailSample.MainPage.OnMailButtonClicked(Object sender, EventArgs e) in MauiSendMailSample\MauiSendMailSample\MainPage.xaml.cs:line 36}
Issue Analytics
- State:
- Created a year ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
NET - Mail server doesn't send mail through SmtpClient.Send
We just added permission for the virtual machine of the web server and the mail is sent normally. SmtpClient client = new SmtpClient();...
Read more >Sending mail with Android and C#, it never returns from ...
I'm implementing the same thing with android and C#, but when the program reaches SmtpServer.Send it freezes on that line. No exception or...
Read more >Why doesn't SmtpClient work correctly in VS 2019 version ...
If I use Send, I get the following exception: Failure sending mail. ---> System.IO.IOException: Unable to read data from the transport ...
Read more >SMTP Send No Longer Working? : r/LabVIEW
The error message says: Error 1172 occurred at Error calling method System.Net.Mail.SmtpClient.Send, (System.Reflection.
Read more >Smtp error while send mail with gmail setting
I am using Gmail setting for sending mail, i got an error like "Failure sending mail." and InnerException as "Unable to read data...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If this is true then this issue needs to be reopened @jfversluis
I just tested the same sample on Xamarin.Forms and on Android/UWP it is working like expected. Only .NET MAUI Android isn’t working as expected.