Sending emails from dotnet8 web application

Daniel Giles 0 Reputation points
2025-03-29T22:57:05.87+00:00

Hi, I have a dotnet8 web application which I am using to send emails from ******@mydomain.com (which is a google workspace account) via a smtp request using the following configuration:
Domain = smtp.gmail.com
Port = 465
A generated App Password stored in my google admin console.

When running the dotnet8 web application on my personal windows machine, it is able to establish a connection using the above configuration and therefore successfully send the email. However, when I deploy my dotnet8 web application to IONOS it is no longer able to establish a connection and thus unable to send the emails. IONOS has ensured me there is nothing on their system that would simply block the request to "smtp.gmail.com", however they also suggested that I may be missing some additional configuration whether it be in my google admin console or there some DNS settings that I need to include. With that in mind, I would greatly appreciate it if you could help me to shed shed some light on this because I have tried several configurations but nothing happening. I have created an SPF record, DKIM, DMARC, verified my domain using google postmaster tools and enabled "less secure app access".

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,815 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. AgaveJoe 30,031 Reputation points
    2025-03-30T10:58:15.2166667+00:00

    For a more robust and secure email solution, modernizing your application and migrating to Google's Gmail API is highly recommended. Utilizing a library like MailKit can simplify this process.

    https://developers.google.com/workspace/gmail/api/guides

    To effectively troubleshoot the current connection problem, the error message is crucial. If you don't have it, adding logging and exception handling will help us trace the application's behavior. Additionally, the use of SSL port 465 is problematic as SSL is outdated and vulnerable. Try switching to port 587, which uses the modern and secure TLS protocol. Finally, Google's 'less secure apps access' is being deprecated; App Passwords are the recommended alternative for secure access but this might not be effective for an app to app connection.

    https://support.google.com/mail/answer/185833?hl=en#zippy=%2Cwhy-you-may-need-an-app-password

    0 comments No comments

  2. Bruce (SqlWork.com) 74,851 Reputation points
    2025-03-31T16:42:28.2033333+00:00

    gmail support of basic authentication ended 3/14/2025:

    https://workspaceupdates.googleblog.com/2023/09/winding-down-google-sync-and-less-secure-apps-support.html

    thus the SmtpClient will no longer work with gmail. currently there are no planned updates to SmtpClient (as its legacy and the update would not be transparent). as suggested you must replace with a library like MailKit that supports modern authentication.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.