Click here to Skip to main content
15,298,916 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am sending mails using my live account and my code works fine on localhost but gives an exception on server:
Mailbox unavailable. The server response was: 5.7.3
Requested action aborted; user not authenticated
Below is my code:
C#
public static string SendEmail(string receivermailid, string subject, string body)
    {
        
        MailMessage MyMailMessage = new MailMessage("xyz@live.com", receivermailid, subject, body);
        MyMailMessage.IsBodyHtml = true;
        NetworkCredential mailAuthentication = new
        NetworkCredential("xyz@live.com", "xxxx");
        SmtpClient mailclient = new SmtpClient("smtp.live.com", 25);
        mailclient.EnableSsl = true;
        mailclient.UseDefaultCredentials = false;
        mailclient.Credentials = mailAuthentication;
        try
        {
            mailclient.Send(MyMailMessage);

            return "Sent successfully";
        }
        catch (SmtpException ex)
        {
            return ex.Message;
        }
Posted
Updated 5-Jul-13 5:18am
v3
Comments
Richard MacCutchan 5-Jul-13 10:56am
   
"doesn't work" is not a very good description of the error. Try adding some useful detail about exactly what happens and what error codes or messages you get.
lucky050 5-Jul-13 11:17am
   
Thanks for the prompt response. It gives an exception:
Mailbox unavailable. The server response was: 5.7.3
Requested action aborted; user not authenticated
Richard MacCutchan 5-Jul-13 11:22am
   
"user not authenticated" suggests that it requires different authentication settings.
lucky050 5-Jul-13 11:37am
   
I should be most grateful if you would send me the sample code..
[no name] 5-Jul-13 11:45am
   
Try using port 587
lucky050 5-Jul-13 12:08pm
   
i changed my port to 587 still its not working but now my method is not returning any message
[no name] 5-Jul-13 12:40pm
   
Okay so your error message went away which was the basis for your question.... what does "still its not working" mean?
idenizeni 5-Jul-13 19:52pm
   
Are you 100% sure the credentials you are supplying are correct and the email account exists on the live.com?
lucky050 6-Jul-13 7:15am
   
yes i m 100% sure... i've changed the credentials to server's mail and its working now.. it could be a firewall issue

1 solution

My guess is either the default credentials or SSL, but it's hard for us to say; We don't have access to your server...

Could be firewall trouble as well!

Good luck!
   
v3

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