Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i am yogesh. i have made a website which enable user to send mails
my problem is that when i am sending mail from my pc that is from local host
everything works good but when i UPLOAD my website on my domain server email is not sent its saying failure sending mail...
my code is....
C#
MailMessage mail = new MailMessage();
            SmtpClient smtp = new SmtpClient();
            MailAddress addressFrm = new MailAddress("softdotnet09@gmail.com");
            mail.From = addressFrm;
            mail.To.Add("iamyogeshsharma@yahoo.com");
            mail.IsBodyHtml = true;
            mail.Body = MSG;
            mail.Subject = "Client Order";
            smtp.Host = "smtp.gmail.com";
            smtp.Port = 587;
            smtp.EnableSsl = true;
            smtp.Credentials = new System.Net.NetworkCredential("softdotnet09@gmail.com", "12345");
            smtp.Send(mail);


please help me what i have to do to send email from my own domain name
example: it is www.example.com
what i have to do... Also explain...
how to use email account that comes with my domain name instead of gmail account...
Any Help wiil be appreciated...thanks..
Posted
Updated 28-Jul-12 5:52am
v2
Comments
[no name] 28-Jul-12 11:59am    
If you have to use your own domain email then why are you asking us? You should be asking whoever your host is.

You need to look in to the ACTUAL error message, it will tell you why your send is failing. Post it here if you are stuck. You shouldn't have to do anything different, if you're sending through gmail and not through a local mail server.
 
Share this answer
 
It can be because of various reasons. You need to look at them one by one.
Is the port open? Firewall permissions in place?
Further make sure you have configured SMTP configuration in Web.Config:
<system.net>
   <mailSettings>
     <smtp from="abc@somedomain.com">
       <network host="somesmtpserver" port="25" userName="name" password="pass" defaultCredentials="true" />
     </smtp>
   </mailSettings>
</system.net>

If needed, have a look at this Microsoft Video tutorial:
Use ASP.NET to send Email from Website[^]
Tutorials on sending Email in ASP.NET[^]

BTW, from next time, always share the exact error you get.
 
Share this answer
 
Comments
yogesh a sharma 29-Jul-12 12:15pm    
i tried it sir my web.config setting is same but i want to know what username and
password i have to use in web.config email account username/password OR What????
I am a bit Confused.. Help Me Sir because my code is working from local host but not from live websit.. i am getting error as....
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.
Please Help Me Sir....
Sandeep Mewara 29-Jul-12 15:31pm    
Your sender accounts username-passowrd that is authorized to send emails.

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