Click here to Skip to main content
15,887,596 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

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!
 
Share this answer
 
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