我没有依赖我的主机发送电子邮件,而是考虑使用我的Gmail帐户发送电子邮件.这些电子邮件是我在节目中播放的乐队的个性化电子邮件.有可能吗?
我想用这段代码使用ASP.NET发送邮件:
public void Semail(string subject, string messageBody, string toAddress)
{
MailMessage mail = new MailMessage();
mail.To.Add(toAddress);
//mail.To.Add("amit_jain_online@yahoo.com");
mail.From = new MailAddress("noreplykaramaoozi@eesharif.edu");
mail.Subject = subject;
string Body = messageBody;
mail.Body = Body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "sina.sharif.ir"; //Or Your SMTP Server Address
smtp.Credentials = new System.Net.NetworkCredential
("noreplykaramaoozi@eesharif.edu", "******");
//Or your Smtp Email ID and Password
smtp.EnableSsl = true;
smtp.Send(mail);
}
Run Code Online (Sandbox Code Playgroud)
但执行后我得到了这个错误:
Syntax error, command unrecognized. The server response was: Dovecot ready.
Run Code Online (Sandbox Code Playgroud)
这是堆栈跟踪
[SmtpException: Syntax error, …Run Code Online (Sandbox Code Playgroud)