Google's email server, Gmail, is wildly popular and is becoming a common service for businesses (via the Google Apps for Business service.) Therefore, it is not surprising that SRP customers often ask how they can send emails through the Gmail service using the SRP Mail utility. As of version 1.2 this can be done using a configuration that accommodates Gmail's concerns for security.

Gmail and SMTP

The SRP Mail utility sends out emails using SMTP and as such appears to Gmail as just another email client. Google has two articles on configuring email clients depending on whether your incoming email is based on POP or IMAP. In either case the configuration for SMTP is the same.

SRP Mail Config Options

Whether you are using a free Gmail account or a domain specific Google Apps account the SMTP server (i.e. field 4 of the Config argument) will always be smtp.gmail.com.

To mitigate spamming Gmail requires that authentication be turned on. This is done by setting field 5 of the Config argument to 1. (Note: This should always be set to 1 unless the SMTP server rejects it.)

Encryption is also a requirement. Google supports two methods of encryption: TLS and SSL. This is enabled by setting field 8 of the Config argument to "SSL" or "TLS" accordingly.

For SSL encryption the Port value (i.e., field 3 in the Config argument) should be set to 465. For TLS encryption, the Port value should be set to 587.

Username should be the full Gmail address including the domain (i.e., myname@gmail.com, Google Apps users would use myname@mydomain.) Password should be the appropriate password for this account.

Code Sample

$insert SRPMAIL_INSERTS 

Message     = "" 
Message<1>  = "Sending email through Gmail" 
Message<2>  = "jamesbond@gmail.com" 
Message<3>  = "ernstblofeld@spectre.org" 
Message<4>  = "" 
Message<5>  = "" 
Message<6>  = "" 
Message<7>  = "TEXT" 
Message<8>  = "Dear Blofeld," : CRLF$ : CRLF$ : "Your cat has been adopted by M. We hope you are enjoying your retirement." 
Message<9>  = "" 
Message<10> = SRPMail_Importance_Normal$ 

Config      = "" 
Config<1>   = SendUsing_Port$ 
Config<3>   = 465 
Config<4>   = "smtp.gmail.com" 
Config<5>   = 1 
Config<6>   = "jamesbond@gmail.com" 
Config<7>   = "Moneypenny1985" 
Config<8>   = "SSL"

rv = SRP_Send_Mail(Message, Config)
  • No labels