Click here to Skip to main content
12,292,585 members (69,608 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET WebForms
I cont able to send a mail using this code: Please help me with this code:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net.Mail;
using System.Net.Mime;
 
public partial class _Default : System.Web.UI.Page
{
MailMessage mail = new MailMessage();
private void clear()
{
TextBox2.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
}
 
protected void Button2_Click(object sender, EventArgs e)
{
 
{ {
 
SmtpClient mailserver = new SmtpClient();
mailserver.Credentials = new System.Net.NetworkCredential ("francis@protonbpo.com", "*******");
// mailserver.Port = 587; //gmail port: 587
mailserver.Host = "smtpout.asia.secureserver.net"; // "smtpout.asia.secureserver.net"; // //"smtp.secureserver.net" "smtp.gmail.com";
mailserver.EnableSsl = false;
mail = new MailMessage();
 
String[] addr = TextBox2.Text.Split(',');
 
try
{
mail.From = new MailAddress("noreply@noreply.net", "HI", System.Text.Encoding.UTF8);
Byte i;
for (i = 0; i < addr.Length; i++)
mail.To.Add(addr[i]);
 
mail.Subject = TextBox4.Text;
mail.Body = TextBox5.Text;
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
mail.ReplyTo = new MailAddress(TextBox2.Text);
mailserver.Send(mail);
Label1.Visible = true;
Label1.Text = "Hi Your Massage Has been sent";
clear();
}
catch (Exception ex)
{
Label1.Visible = true;
Label1.Text = "mail not sent "+ ex.ToString();
}
}
}
}
protected void Button1_Click (object sender, EventArgs e)
{
clear();
}
}

This is the error i am getting:

mail not sent System.Net.Mail.SmtpFailedRecipientExcep… Mailbox name not allowed. The server response was: sorry, relaying denied from your location [183.83.83.176] (#5.7.1) at System.Net.Mail.SmtpTransport.SendMail(M… sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception) at System.Net.Mail.SmtpClient.Send(MailMess… message) at _Default.Button2_Click(Object sender, EventArgs e) in
Posted 2-Aug-11 21:55pm
Edited 2-Aug-11 22:24pm
thatraja247.9K
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

what I see from the error is that you use a different mail server than the network you are in. So that is way it is saying that relaying is denied.

and set: mailserver.DeliveryMethod = SmtpDeliveryMethod.Network;

Which mail client do you use on your development system?
  Permalink  
v2
Comments
manoharnch 3-Aug-11 4:06am
   
Godaddy
digimanus 3-Aug-11 4:50am
   
view http://rtur.net/blog/post/SMTP-with-GoDaddy.aspx for all detail settings
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

The link digimanus posted works like a charm thank you very much!
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160518.1 | Last Updated 24 Aug 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100