Prolemare
Posts: 1
|
Posted: 05/20/2015, 1:52 AM |
|
I want to send EMail from my Website hosted at http://hostforlife.eu, and we are using Google Apps for Emails. Here is my code in ASP.Net/ C#,
MailMessage mMailMessage = new MailMessage();
mMailMessage.From = new MailAddress("utility@mydomain.com", "GotFeedback", System.Text.Encoding.UTF8);
mMailMessage.To.Add(new MailAddress("feedback@mydomain.com"));
mMailMessage.Subject = "subject";
mMailMessage.SubjectEncoding = System.Text.Encoding.UTF8;
mMailMessage.Body = body;
mMailMessage.BodyEncoding = System.Text.Encoding.UTF8;
mMailMessage.IsBodyHtml = true;
mMailMessage.Priority = MailPriority.Normal;
SmtpClient mSmtpClient = new SmtpClient();
mSmtpClient.UseDefaultCredentials = false;
mSmtpClient.Credentials = new System.Net.NetworkCredential("utility@mydomain.com", "mypassword");
mSmtpClient.Host = "SMTP.GOOGLE.COM";
mSmtpClient.Port = 587;
mSmtpClient.EnableSsl = true;
try
{
mSmtpClient.Send(mMailMessage);
}
catch(Exception e)
{
string edsf = e.ToString();
But I am getting Exception that it is unable to connect to remote server Please help. Thanks!
|
 |
 |
eratech
Posts: 513
|
Posted: 05/20/2015, 5:46 AM |
|
Prolemare
Not specific to CodeCharge, but there are a number of things that might be getting in the way:
- network firewall settings not allowing SMTP traffic on port 587
- smtp server address - I've seen references to 'smtp.gmail.com' as well ( https://www.digitalocean.com/community/tutorials/how-to...e-s-smtp-server )
- the port - sometimes 587 doesn't work for some SSL and 465 is needed
- have you activated SMTP Relay for your google apps account? ( https://support.google.com/a/answer/2956491?hl=en )
Can you post the exact error message?
Cheers
Eric
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia |
 |
 |
|