Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#ASP.NETWebForms
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
thatraja230.2K
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 at 3-Aug-11 4:06am
   
Godaddy
digimanus at 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
Your Filters
Interested
Ignored
     
0 Guruprasad.K.Basavaraju 490
1 Shai Vashdi 339
2 Sergey Alexandrovich Kryukov 291
3 Peter Leow 135
4 praveen_07 115
0 Sergey Alexandrovich Kryukov 9,185
1 OriginalGriff 5,335
2 Peter Leow 4,040
3 Maciej Los 3,540
4 Abhinav S 3,308


Advertise | Privacy | Mobile
Web02 | 2.8.140415.2 | Last Updated 24 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid