PDA

View Full Version : سوال: مشكل با SMTP Server و ارسال ايميل با آن



merlin_vista
چهارشنبه 06 شهریور 1387, 14:34 عصر
سلام . آقا من ميخواهم با SMTP سرويس Gmail از برنامه خودم ايميل بفرستم نميشه !!
اين پبغام خطا را ميده .


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. c2sm10813833ana.10

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Mail.SmtpException: 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. c2sm10813833ana.10در ضمن اين كد ارسال ايميل من هست :


//Body : For Delete ::::
StreamReader pr = File.OpenText(HttpContext.Current.Server.MapPath("Images//EmailHtml//NotReg.txt"));
string body = pr.ReadToEnd();
pr.Close();
body = body.Replace("#Name#", Name);
body = body.Replace("#Email#", Email);
body = body.Replace("#RegDate#", Date);
body = body.Replace("#Link#", ConfigurationManager.AppSettings.Get("urlsit").ToString() + "/newsletter_acitve.aspx?control=" + controlCode + "&id=" + id + "&Taype=2");

//send Email :
MailMessage mail = new MailMessage();
mail.From = new MailAddress(ConfigurationManager.AppSettings["NewsLater_email"].ToString(), "Newsletter AsanDownload", System.Text.Encoding.GetEncoding("windows-1256"));
mail.To.Add(Email);
mail.Subject = "Newsletter AsanDownload";
mail.SubjectEncoding = System.Text.Encoding.UTF8;
mail.Body = HttpContext.Current.Server.HtmlDecode(body);
mail.IsBodyHtml = true;
mail.BodyEncoding = System.Text.Encoding.UTF8;
mail.Priority = MailPriority.High;
SmtpClient smtp = new SmtpClient(ConfigurationManager.AppSettings["NewsLater_smtp"].ToString());
smtp.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["NewsLater_email"].ToString(), ConfigurationManager.AppSettings["NewsLater_PassWord"].ToString());
smtp.Send(mail);و اين هم كد وب.كانفيگ من :


<appSettings>
<add key="FCKeditor:BasePath" value="~/fckeditor/"/>
<add key="NewsLater_smtp" value="smtp.gmail.com"/>
<add key="NewsLater_email" value="asan.newsletter@gmail.com"/>
<add key="NewsLater_PassWord" value="******"/>
</appSettings>

Neo Persian
چهارشنبه 06 شهریور 1387, 19:52 عصر
اينو اضافه كن:


smtp.EnableSsl = true;