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 ="rpanchal@itaxsmart.com";
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Credentials = new System.Net.NetworkCredential("EmailId@domain.com","**");
MailAddress fromAddress = new MailAddress("myEmailId@domain.com", "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?
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.