I tried to send an email using the following code:
MailMessage message = new MailMessage(); message.From = new MailAddress(fromMailAddress.Trim()); message.To.Add(new MailAddress(toMailAddress.Trim())); message.Subject = subject; message.Body = body; message.SubjectEncoding = System.Text.Encoding.UTF8; message.BodyEncoding = System.Text.Encoding.UTF8; SmtpClient client = new SmtpClient(); try { client.Send(message); } catch(Exception e) { throw e; }
However, I got an exception:
Server response: 5.5.4 Invalid address
Everything is correct on behalf of email, email, server host name and port. The exact same code with the same input values ββworks on another machine in our office
source share