Reputation: 881
I want to send email with my web application. It is published on rackspace dedicated server but I'm using GoDaddy's SMTP server to send email.
The fault I'm getting is:
System.Net.Mail.SmtpFailedRecipientException: Mailbox name not allowed. The server response was: sorry, relaying denied from your location [xx.xx.xxx.xx] (#5.7.1)
This is my code
SmtpClient client = new SmtpClient("relay-hosting.secureserver.net", 25);
string to ="[email protected]";
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Credentials = new System.Net.NetworkCredential("[email protected]","**");
MailAddress fromAddress = new MailAddress("[email protected]", "CompanyName");
MailMessage message = new MailMessage();
message.From = fromAddress;
message.To.Add(to);
message.Body = "This is Test message";
message.Subject = "hi";
client.Send(message); message.Dispose(); return "Email Send";
Should I do any configuration on dedicated server?
Upvotes: 1
Views: 2434
Reputation: 31
That is so simple:
You must focus on smtp host, port, ssl... Change smtp host to: relay-hosting.secureserver.net And DELETE port and ssl, thats all... Do not use smtp port and smtp ssl true or false
var fromAddress = "mailfrom@yourdomain";
// any address where the email will be sending
var toAddress = "mailto@yourdomain";
//Password of your mail address
const string fromPassword = "******";
// Passing the values and make a email formate to display
string subject = TextBox1.Text.ToString();
string body = "From: " + TextBox2.Text + "\n";
body += "Email: " + TextBox3.Text + "\n";
body += "Subject: " + TextBox4.Text + "\n";
body += "Message: \n" + TextBox5.Text + "\n";
// smtp settings
var smtp = new System.Net.Mail.SmtpClient();
{
smtp.Host = "relay-hosting.secureserver.net";
**//Warning Delete =>//smtp.Port = 80;**
**//Warning Delete =>//smtp.EnableSsl = false;**
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
smtp.Timeout = 20000;
}
// Passing values to smtp object
smtp.Send(fromAddress, toAddress, subject, body);
Upvotes: 0
Reputation: 1
Start trying to change your port 465 instead 25.
Or remember Relay-hosting is very limited to 250 emails per day and not accept remote connections so easy. Check if you can use SSL connection.
Upvotes: 0
Reputation: 61
If you are hosting with RackSpace you should use the SMTP RackSpace recommends for sending from their servers. Unfortunately, you can only use relay-hosting.secureserver.net if you are sending from go Daddy Shared or 4GH hosting.
Upvotes: 0
Reputation: 7375
Are you testing locally? If yes, then your SMTP server may not allow relaying. Do not worry when you will deploy the application there won't be any problem.
Upvotes: 2