Sending mail through C# with gmail is not working after deploying to host
Edit: OP Added extra information crucial to answering this question, but I'm keeping the old answer around as it might still help someone
New Answer: This StackOverflow question already answered this question
OldAnswer:
As this StackOverflow answer already answered, you changed the Port on the SMTP Server to 587
instead of its default (25
) and this requires elevated permissions causing this error change this:
SmtpServer.Port = 587;
to this:
SmtpServer.Port = 25;
and it should work
Note: When using SSL the port needs to be 443