I am using this code but getting an error:
SmtpClient smtp_client = new SmtpClient();
MailMessage web_mailer = new MailMessage();
web_mailer.From = mailer_from;
web_mailer.To.Add(Session["member_email"].ToString());
web_mailer.Subject = "????? ??????? ?? ??????";
web_mailer.Body = email_body;
web_mailer.IsBodyHtml = true;
web_mailer.BodyEncoding = Encoding.GetEncoding("windows-1256");
web_mailer.Priority = MailPriority.High;
web_mailer.Headers.Add("X-Organization", "BahrainPolls.org");
web_mailer.Headers.Add("TrackingID", record_guid.ToString());
// smtp_client.Host = "localhost";
smtp_client.Host = "smtp.gate.com";
smtp_client.Port = 25;
smtp_client.Send(web_mailer);
this is the error:
System.Net.Mail.SmtpException was unhandled by user code
Message="Syntax error, command unrecognized. The server response was: Unauthorized relay msg rejected "
Source="System"
StackTrace:
at System.Net.Mail.RecipientCommand.CheckResponse(SmtpStatusCode statusCode, String response)
at System.Net.Mail.RecipientCommand.Send(SmtpConnection conn, String to, String& response)
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at ASP.confirm_signup_aspx.btnRegister_Click(Object sender, EventArgs e) in c:\Documents and Settings\Jassim Rahma\My Documents\Visual Studio 2005\WebSites\Bahrain Public Opinion Polling\confirm_signup.aspx:line 118
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
From here (http://www.systemwebmail.com/faq/4.3.11.aspx):
System.Web.Mail is working correctly, and is attempting to send theemail. However, your SmtpMail.SmtpServer is not allowing relaying. Tryone of the following suggestions:Make sure the MailMessage.From is a valid email address that exists on the SmtpMail.SmtpServer.
0 comments:
Post a Comment