1

I am creating my mvc app. I would like to send email to users that register. I do it like this:

MailMessage mail = new MailMessage();
mail.To.Add(user1.email.Replace(" ", string.Empty));
mail.From = new MailAddress("declarations@virtual.mini.pw.edu.pl");
mail.Subject = "Class Declaration System user creation confirmation.";
string body = "Dear " + user1.name + ",\n This is to confirm that you have succesfully registered in the system. \n Do not reply to this message. \n Regards";
mail.Body = body;
mail.IsBodyHtml = true;
var smtp = new SmtpClient();
smtp.EnableSsl = true;
smtp.Host = "poczta.mini.pw.edu.pl";
smtp.Port = 25;

And everything seems fine. I have contacted the administrator of the server and I am sending everything through a right port. However, I get an error:

Command parameter not implemented. The server response was: 5.5.2
> <WIN-KI3H68FIO4E>: Helo command rejected: need fully-qualified hostname

The administrator told me that this is because I am trying to send it as WIN-KI3H68FIO4E, but it should be something.mini.pw.edu.pl, since we have such restrictions here. How do I change it in my code?

Maciej Miśkiewicz
  • 412
  • 2
  • 8
  • 22
  • Exactly as you have done. You're already setting the host to `poczta.mini.pw.edu.pl`. Can you clarify your question more? – Chris Pratt May 31 '17 at 15:37
  • Well, the administrator said that the logs say that message is submitted by , which is a server name (where the app works), which is not accepted by the mailing server. Mailing server will accept it only if the submitter is xxx.mini.pw.edu.pl @ChrisPratt – Maciej Miśkiewicz May 31 '17 at 15:41
  • That's mail server config issue. You can't control that in code. The host the request is coming from is based on the network configuration. It looks like the web server and the mail server are on the same local network, which means they'll be identified by their local host names. Your mail admin either needs to allow communication from that hostname or your web server would have to be put outside the local network, such that it will be identified by it's external FQN. – Chris Pratt May 31 '17 at 15:47

1 Answers1

0

The answer was to edit the web.config file and to add there custom ClientDomain.

Maciej Miśkiewicz
  • 412
  • 2
  • 8
  • 22