This is my mail sending code. I got the error "Invalid character in the mail header." When I changed the name of my computer to the shortest. The problem is resolved. But in my domain, the names of all computers, such as "04500-ab04545.xxxdomain.gov.tr", so I need to find another solution for this problem.
Therefore, I cannot give a static computer name when sending mail from C # code.
MailMessage msg = new MailMessage();
msg.Body = "axxxxxx";
msg.To.Add(new MailAddress("xxxx@xxxx.domain"));
msg.From = new MailAddress("xxxx@xxxx.domain","blab blalb");
msg.Subject = "Subject xxx";
SmtpClient server = new SmtpClient("xxxxxxxx",25);
server.Credentials = new NetworkCredential("xxxxx", "xxxxxxx");
SmtpClient server = new SmtpClient("mail.adalet.gov.tr",25);
server.Credentials = new NetworkCredential("xxx", "xxx");
server.Send(msg);
source
share