Sending mail....problem
-
Hi to all, I am trying to send the "contact us" from data to email on submit button click. But giving this error.
Server Error in '/VICTORIAIN' Application.
Mailbox unavailable. The server response was: not local host hotmail.com, not a gateway
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.SmtpFailedRecipientException: Mailbox unavailable. The server response was: not local host hotmail.com, not a gateway
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SmtpFailedRecipientException: Mailbox unavailable. The server response was: not local host hotmail.com, not a gateway]
System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception) +858231
System.Net.Mail.SmtpClient.Send(MailMessage message) +2004
Contact_Us.send_data_to_mail() +189
Contact_Us.BtnSubmit_Click(Object sender, EventArgs e) +18
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433
I am using this code:
SmtpClient smtpClient = new SmtpClient(); MailMessage message = new MailMessage(); MailAddress fromAddress = new MailAddress(TxtEmail.Text, TxtName.Text); message.From = fromAddress; message.To.Add("rohanrajpoot@in.com"); message.Subject = "This person has contacted us!"; message.IsBodyHtml = false; message.Body = TxtMessage.Text; smtpClient.Send(message);
In web.config I did this:
<system.net>
<mailS -
Hi to all, I am trying to send the "contact us" from data to email on submit button click. But giving this error.
Server Error in '/VICTORIAIN' Application.
Mailbox unavailable. The server response was: not local host hotmail.com, not a gateway
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.SmtpFailedRecipientException: Mailbox unavailable. The server response was: not local host hotmail.com, not a gateway
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SmtpFailedRecipientException: Mailbox unavailable. The server response was: not local host hotmail.com, not a gateway]
System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception) +858231
System.Net.Mail.SmtpClient.Send(MailMessage message) +2004
Contact_Us.send_data_to_mail() +189
Contact_Us.BtnSubmit_Click(Object sender, EventArgs e) +18
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433
I am using this code:
SmtpClient smtpClient = new SmtpClient(); MailMessage message = new MailMessage(); MailAddress fromAddress = new MailAddress(TxtEmail.Text, TxtName.Text); message.From = fromAddress; message.To.Add("rohanrajpoot@in.com"); message.Subject = "This person has contacted us!"; message.IsBodyHtml = false; message.Body = TxtMessage.Text; smtpClient.Send(message);
In web.config I did this:
<system.net>
<mailSsneha Choudhary wrote:
Does SMTP configure Properly ?
cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net My Latest Article : IIS Remote Debugging
-
Hi to all, I am trying to send the "contact us" from data to email on submit button click. But giving this error.
Server Error in '/VICTORIAIN' Application.
Mailbox unavailable. The server response was: not local host hotmail.com, not a gateway
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.SmtpFailedRecipientException: Mailbox unavailable. The server response was: not local host hotmail.com, not a gateway
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SmtpFailedRecipientException: Mailbox unavailable. The server response was: not local host hotmail.com, not a gateway]
System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception) +858231
System.Net.Mail.SmtpClient.Send(MailMessage message) +2004
Contact_Us.send_data_to_mail() +189
Contact_Us.BtnSubmit_Click(Object sender, EventArgs e) +18
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433
I am using this code:
SmtpClient smtpClient = new SmtpClient(); MailMessage message = new MailMessage(); MailAddress fromAddress = new MailAddress(TxtEmail.Text, TxtName.Text); message.From = fromAddress; message.To.Add("rohanrajpoot@in.com"); message.Subject = "This person has contacted us!"; message.IsBodyHtml = false; message.Body = TxtMessage.Text; smtpClient.Send(message);
In web.config I did this:
<system.net>
<mailSI agree with the previous comment, it seems like your SMTP mail server must be configured incorrectly in your
web.config
file. I tested your code (slightly modified), usinglocalhost
as the mail server; it worked just fine.//Test Strings
string TxtEmail = "Sue.Smith@123.com";
string TxtName = "Sue Smith";
string TxtMessage = "This is a test email message.";using(MailMessage message = new MailMessage())
{
message.From = new MailAddress(TxtEmail, TxtName);
message.To.Add(new MailAddress("rohanrajpoot@in.com"));
message.Subject = "This person has contacted us!";
message.IsBodyHtml = false;
message.Body = TxtMessage;
SmtpClient smtpClient = new SmtpClient { Host = "localhost" };
smtpClient.Send(message);
}Regards, Gary