Solved

Issues Sending Mail Google Apps ASP.Net

Posted on 2009-04-01
2
510 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

803 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