Solved

Issues Sending Mail Google Apps ASP.Net

Posted on 2009-04-01
2
512 Views
Last Modified: 2013-12-17
Currently I am attempting to send an email using my google apps account which is registered properly for my domain. Upon running the code below I receive the error.

The remote certificate is invalid according to the validation procedure.
MailMessage message = new MailMessage();
            message.To.Add(to);
            message.From = new MailAddress("me@mydomain.com", "myname", System.Text.Encoding.UTF8);
            message.Subject = subject;
            message.SubjectEncoding = System.Text.Encoding.UTF8;
            message.Body = message2;
            message.BodyEncoding = System.Text.Encoding.UTF8;
            message.IsBodyHtml = false;
            message.Priority = MailPriority.Normal;
            SmtpClient emailClient = new SmtpClient();
            emailClient.Credentials = new NetworkCredential("me@mydomain.com", "secret");
            emailClient.Port = 587;
            emailClient.Host = "smtp.gmail.com.";
            emailClient.EnableSsl = true;
            emailClient.Send(message);

Open in new window

0
Comment
Question by:greggoodwin2
2 Comments
 
LVL 5

Accepted Solution

by:
KPMT-Technician earned 500 total points
ID: 24042415
I have a few questions:
  Is the machine that is running this web appication have the ablitity to communication with google via port 587?
  Is the machine that is running this web application behind a firewall?
  Line 11 on the above sample code - Are the Network Credential a valid Google email address?

Comment:
  Line 13 on the above sample code - "smtp.gmail.com." remove the last (.) - type-o only, dns will resovle the correct IP Address with or without it.
0
 

Author Closing Comment

by:greggoodwin2
ID: 31565416
Thanks I opened the ports on the web server and removed the (.) now it all runs well!
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question