views:

159

answers:

2

Hello, I want to send EMail from my Website hosted at GoDaddy, and we are using Google Apps for Emails.

Here is my code in ASP.Net/ C#

    MailMessage mMailMessage = new MailMessage();
    mMailMessage.From = new MailAddress("[email protected]", "GotFeedback", System.Text.Encoding.UTF8);
    mMailMessage.To.Add(new MailAddress("[email protected]"));
    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("[email protected]", "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

A: 

If google is hosting your email thru Google apps, try using smtp.yourdomain.com as the SMTP host.

Ed B
+2  A: 

I would imagine they block outside SMTP server connections. I believe you should be able to use your GoDaddy.com SMTP server to send email out.

Looking at the help here: Using CDOSYS to Send Email from Your Windows Hosting Account

It says that you must use: "relay-hosting.secureserver.net" to send email.

rifferte
Thanks rifferte...It worked