Forum guidelines
AuthorQuestion
mail was not sent after hosting the aplication
Posted By Suresh Babu on 14 Sep 2013
hi
plese help me

i had developed a web application.. in my application i need to sent a mail to customer.. if i run my application in local system its the mail was sent successfully. but after hosting the application  the mail was not sent
this is my code
  
SmtpClient client = new SmtpClient();
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            client.EnableSsl = true;
            client.Host = "smtp.gmail.com";
            client.Port = 587;

          
            System.Net.NetworkCredential credentials =
                new System.Net.NetworkCredential("suresh57.amt@gmail.com", "suresh57");
            client.UseDefaultCredentials = false;
          
            client.Credentials = credentials;

            MailMessage msg = new MailMessage();
            msg.From = new MailAddress("suresh57.amt@gmail.com");
            msg.To.Add(new MailAddress(to));

            string BccAddress = "softwarebackup@rediffmail.com";
            msg.Bcc.Add(BccAddress);

            msg.Subject = subject;
          
            msg.Body = body;

            try
            {
                client.Send(msg);
                res = true;
          
            }
            catch (Exception ex)
            {
          
          
            }

AuthorReply
Re: mail was not sent after hosting the aplication
Posted By Sanjeeb Lenka on 14 Sep 2013  
hi,

your code looks correct. may be your mail going to spam or junk folder check that.
Also check by changing port no 587 to 25. it may help you.

"If you Dream it You can do it"
Re: mail was not sent after hosting the aplication
Posted By Suthish Nair on 17 Sep 2013  
Port 587 and 25, both are meant for different server's. Do not mix up both. Also, check any exception you getting from try catch. Write the exception to Event Log entry and check. Also, did SMTP configured on your server, also you must setup GMAIL SMTP configuration.
Mark as Answer, on the posts reply's that helped you !!!.

SPONSORED BY

Custom Software Development
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.