title: Amazon WorkMail timeout .net core SmtpClient
body: <p>I am trying to send a standard email message through AWS WorkMail using the SmtpClient in .NET Core. The configuration is very standard according to Amazon Documentation:
  <a href="https://docs.amazonaws.cn/en_us/general/latest/gr/workmail.html" rel="nofollow noreferrer">https://docs.amazonaws.cn/en_us/general/latest/gr/workmail.html</a></p>
  
  <pre><code>  "Smtp": {
      "MailServer": "smtp.mail.eu-west-1.awsapps.com",
      "MailPort": "465",
      "SenderName": "Us us us",
      "FromAddress": "email@domain.com",
      "Username": "email@domain.com",
      "Password": "Password1$",
      "EnableSsl": "true"
    },
  </code></pre>
  
  <p>The settings are injected and the SmtpClient gets properly instantiated and the sending of the email is just:</p>
  
  <pre><code>        var mail = new MailMessage
          {
              From = new MailAddress(_smtpSettings.FromAddress, _smtpSettings.SenderName),
              SubjectEncoding = Encoding.UTF8,
              BodyEncoding = Encoding.UTF8,
              IsBodyHtml = true,
              Body = message,
              Subject = subject,
              Priority = MailPriority.High
          };
          mail.To.Add(new MailAddress(sendToEmail));
  
          _smtpClient.Send(mail);
  </code></pre>
  
  <p>Sadly, the sending always fails with a gateway timeout. We tried switching for 587 for STARTTLS and providing the Username without the domain (@). The server sending has proper SSL certificate installed and the mailserver is exactly the one we have our smtp on. Although this would not be a relevant solution, I also increased the timeout to 10 seconds (even though this would not be a solution).</p>
  
  <p>Any idea what could be wrong? I am tearing my hair already. Seems to be an issue with AWS WorkMail.</p>