Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi all,
i need advice
i create sent email class and i can send to any mails inside My company domain but if i need to send an email to another as hotmail or yahoo ,etc i got this Error :
Server Error in '/' Application.

Mailbox unavailable. The server response was: 5.7.1 Unable to relay

please any Advice and this is my code :
C#
MailMessage objEmail = new MailMessage();
objEmail.To.Add(txtTo.Text);
objEmail.CC.Add(txtcc.Text);
objEmail.Subject = "Test Email";
objEmail.Body = txtName.Text;
objEmail.Priority = MailPriority.High;
SmtpClient ss = new SmtpClient("mail.Mycompany.com");

ss.Port = 25;
ss.UseDefaultCredentials = true;

try
{
   ss.Send(objEmail);
   Response.Write("Your Email has been sent sucessfully -  Thank You");
}
catch (Exception exc)
{
   Response.Write("Send failure: " + exc.ToString());
}
Posted
Updated 14-Jul-15 5:14am
v3

You need to speak to whoever administers the smtp server you are using and ask them what you need to do to allow relaying, or to configure relaying as possible from internal servers. Basically the problem isn't your code, it is configuration.
 
Share this answer
 
Are you sure that smtp is not blocked by firewall?
 
Share this answer
 
Comments
Member 10875212 14-Jul-15 9:37am    
not blocked
xszaboj 14-Jul-15 9:45am    
In that case have you tried to google your error?
Here is for example one of explanation for it:
http://stackoverflow.com/questions/15717743/mailbox-unavailable-the-server-response-was-5-7-1-unable-to-relay-error

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900