You must Sign In to post a response.
  • Category: ASP.NET

    Problem on Sending Mail on Live

    Hi Developers ,

    I have a mail function in my code mail is sends Successfully on Localhost.
    But the same code does not working Exactly on live(when host to our server).
    Mails sends only for Gmail account(
    Does not send yahoo, etc(
    My Code is below,

    public void EmailSend(string frmID, string frmName, string toID, string subMsg, String BodyMsg, bool status)
    SmtpClient smtpclient = new SmtpClient();
    MailMessage message = new MailMessage();
    MailAddress fromAddress = new MailAddress("", "");
    smtpclient.Host = "";
    smtpclient.Port = 587;
    message.From = fromAddress;
    message.Subject = subMsg;
    message.Body = BodyMsg;
    message.BodyEncoding = System.Text.Encoding.ASCII;
    message.IsBodyHtml = status;
    message.Priority = MailPriority.High;
    NetworkCredential ocredential = new NetworkCredential("", "12345");
    smtpclient.UseDefaultCredentials = false;
    smtpclient.Credentials = ocredential;
    catch { }

    in Live i have changed below lines

    smtpclient.EnableSsl=false ;
    smtpclient.UseDefaultCredentials =true ;

    Any possible to rectify this error. help me friends

    Thanking you
  • #767264
    what SMTP address you are providing for sending mail to Yahoo
    for yahoo the smtp should be ''
    look at below code for sending mail to yahoo mail

    using System.Net;
    using System.Net.Mail;

    string smtpAddress = "";
    int portNumber = 587;
    bool enableSSL = true;

    string emailFrom = "";
    string password = "abcdefg";
    string emailTo = "";
    string subject = "Hello";
    string body = "Hello, I'm just writing this to say Hi!";

    using (MailMessage mail = new MailMessage())
    mail.From = new MailAddress(emailFrom);
    mail.Subject = subject;
    mail.Body = body;
    mail.IsBodyHtml = true;
    // Can set to false, if you are sending pure text.

    mail.Attachments.Add(new Attachment("C:\\SomeFile.txt"));
    mail.Attachments.Add(new Attachment("C:\\"));

    using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber))
    smtp.Credentials = new NetworkCredential(emailFrom, password);
    smtp.EnableSsl = enableSSL;

    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #767268
    Thanks mr.Prasad.

    Mail is sending local is fine.
    in live it does not sent to any mail ids with default credential.(, 587)

    so am using my Office server credentials(,25)
    in this credentials mail sent only for gmail and yahoo ids.(,
    if i give email id like or na mail does not sent.

    now this is my problem. how i am solve this problem .

    if i use Default Credentials (,587) na
    how am using it hosting on Live.
    how am sent mail to all type of mail accounts using Default Credentials (,587) on live


  • #767280
    If you are using SMTP as '' then you need to provide your Gmail emaiId and pwd in credentials.
    For '' you need to provide your Yahoo emaiId and pwd in credentials.
    For '' you need to provide your Rediff emaiId and pwd in credentials.
    If you want to set up any other smtp service like as you said '','' etc. Then follow these steps:
    Or just configure 'SMTP Email' from IIS where your application is hosted as follows:

  • #767286
    HI ,

    Try this.

Sign In to post your comments