Use Google Apps Gmail to Send Email From Your Domain

I have been using and reccomending Google Apps for Business for almost a year now.  It is a wonderful time saver (especially for a programmer who doubles as IT guy). Google essentially offers your business to move all of their office features, including email, into Google’s cloud.  You can brand everything and you have the reliability and ease of use that Google provides in Gmail, Google Docs, Google Calendar, Google Talk and more.  Check out Google Apps for business.  It is simple to add users and manage everything from the control panel, it is everything you would expect from Google.

I did not put much effort into it, but when I first switched over I could not get my websites emailing agent to work with it.  Since we had ten months left on our current email contract, I never looked into it again.  Now that the other contract has expired, I am forced to use a new mailing service.  I tried setting it up as if it were Gmail, read through all sorts of articles on how to use Gmail as the agent and still no luck.

After hours of just playing around with settings, I am now able to send email through gmail from my own domain.  The only issue that I have come across is that unlike other services, you cannot specify who the email is coming from.  Gmail automatically strips that information out and replaces it with the account you use to login in to’s default information.  You can change the default information from inside of Gmail under Settings -> Accounts.

 

using System.Net.Mail;
private void SendMail()
{
MailMessage message = new MailMessage();
message.To.Add( "testing@anydomain.com" ); 
message.From = new MailAddress( "email@mydomain.com", "Name to Display"
System.Text.Encoding.UTF8 );
message.Subject = "Testing";
message.SubjectEncoding = System.Text.Encoding.UTF8; 
message.Body = "Testing 123";
message.BodyEncoding = System.Text.Encoding.UTF8;
message.IsBodyHtml = false;
message.Priority = MailPriority.Normal;
SmtpClient emailClient = new SmtpClient();
emailClient.Credentials =  new NetworkCredential( "username@mydomain.com", "yourpassword" );
emailClient.Port = 587;
emailClient.Host = "smtp.gmail.com"
emailClient.EnableSsl = true; 
emailClient.Send( message );
}

54 comments » Write a comment

Leave a Reply

Required fields are marked *.