我正在使用 c# 在 mvc4 中做我的项目。我的网站上有一个联系页面。我的需要是在单击“发送”按钮时,我必须从其他 ID 接收到我的电子邮件 ID 的消息。我使用以下代码
public void ReceiveMail(string name,string email,string message)
{
MailMessage msg = new MailMessage();
HttpContext ctx = HttpContext.Current;
msg.To.Add(new MailAddress("MyEmailId"));
msg.From = new MailAddress(email);
msg.Subject =name + "send a message";
msg.Priority = MailPriority.High;
msg.Body = message;
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");// i am confused what to write here
SmtpServer.Send(msg);
}
它显示错误
The SMTP server requires a secure connection or the client was not authenticated.
The server response was: 5.7.0 Must issue a STARTTLS command first.
at4sm42219747pbc.30 - gsmtp
我不知道我从哪个服务器收到邮件。那我该如何解决这个问题。请帮我