Revision: 26245
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at April 21, 2010 10:44 by pckujawa
Initial Code
string host = "smtp.gmail.com"; int port; //port = 587; // with TLS //port = 465; // with SSL port = 25; // normal - works for my gmail account with enableSSL string fromEmail = "[email protected]"; var fromAddress = new MailAddress(fromEmail); var toAddress = new MailAddress("[email protected]"); MailMessage message = new MailMessage(fromAddress, toAddress) { Subject = "subject", Body = "body", }; var smtp = new SmtpClient(host, port) { Credentials=new NetworkCredential(fromEmail, "password"), EnableSsl = true, Timeout = 30000, }; try { smtp.Send(message); } catch(SmtpException se) { //log } message.Dispose();
Initial URL
http://www.google.com/support/forum/p/Google+Apps/thread?tid=3abf482d7d7e24d3&hl=en&fid=3abf482d7d7e24d3000484c10943499b
Initial Description
For both gmail and gApps, use smtp.gmail.com on port 25 with SSL and NetworkCredentials. Neither can send email to their own address, but they can send to other addresses. [NLog](http://nlog-project.org/) has [an example](http://nlog-project.org/wiki/Using_NLog_with_GMail) of how to automatically send emails in order to log info from an app.
Initial Title
Sending emails (particularly with gmail and google apps for domains)
Initial Tags
Initial Language
C#