Forums / Install & configuration / Sending Mail via gmail or Google Apps SMTP

Sending Mail via gmail or Google Apps SMTP

Author Message

Stefan Kolarov

Monday 26 May 2008 6:00:46 am

Hello

I want to configure ezpublish 4.0.0 to send emails through a Google Apps account. The problem is that Google Apps is using SSL to encode SMTP access, and I can not see how to configure this in ezpublish.

Best regards
Stefan

Björn Dieding@xrow.de

Monday 26 May 2008 11:42:07 am

not possible at the moment

Looking for a new job? http://www.xrow.com/xrow-GmbH/Jobs
Looking for hosting? http://hostingezpublish.com
-----------------------------------------------------------------------------
GMT +01:00 Hannover, Germany
Web: http://www.xrow.com/

Stefan Kolarov

Sunday 01 June 2008 7:18:04 am

I did some research, and I hope this brief summary would help the others which would like to use GMail as their SMTP servers.

For those who prefer GMail/Google Apps mail as a mail server, I am posting brief note about the available options. The explanation is generic, and not limited to particular verions of eZ Publish, or even to eZ Publish. Since eZ Publish 4.0.0 is used as example, I would remind the eZ Publish 4.0.0 users to check http://ez.no/doc/ez_publish/technical_manual/4_0/reference/configuration_files/site_ini/mailsettings/transport in case of problems accessing the local SMTP service.

There are two options for sending email through GMail from CMS withouth SMTP/TLS support:
1. Installation of a SSL tunnel, which encrypts the plan SMTP communication between your CMS mailer and Google's SMTP server.
2. Configuration of a smart (http://en.wikipedia.org/wiki/Smart_host) host mail transport agent (MTA) which sends the mails on CMS's behalf through GMail. Needless to say, this email server needs to be both supported by the CMS, and to support TLS relaying of SMTP. If TLS relaying of SMTP is not supported, we still have the same two options, and sort of infinte recursion.

1. A SSL tunnel can be found on http://stunnel.org. On a Linux distribution, chances are that it is available through the distribution's package manager. On my Ubuntu 8.04, I write

sudo apt-get install stunnel4

, enable the service in

/etc/default/stunnel

, and edit the stunnel configuration file:

sudo nano /etc/stunnel/gmail-smtp.conf

:

#...
; Use it for client mode
client = yes

; Service-level configuration
[ssmtp]
accept  = 1925
connect = smtp.gmail.com:465

Then, I configure the mail client of my CMS to use server on localhost:1925 (not smtp.gmail.com), and that's it. As a fast check, I type

telnet localhost 1925
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 mx.google.com ESMTP XXXXXXXXXXXXX

(just write <i>quit</i> to get out.)

For eZ Publish, mail settings would be:

[MailSettings]
Transport=SMTP
TransportServer=localhost:1925
TransportUser=name@gmail.com
TransportPassword=pASSwor-d
AdminEmail=name@gmail.com
EmailSender=name@gmail.com

2. As an example for the smart host solution, I am presenting an Exim 4 MTA configuration. Please, make sure you do understand implications of installation (re)configuration and securing of a mail server before you continue.
Debian and Ubuntu users may look at http://wiki.debian.org/GmailAndExim4 for detailed step-by-step instructions. After the procedure my

/etc/exim4/update-exim4.conf.conf

looked like this:

#...
# This is a Debian specific file
dc_eximconfig_configtype='satellite'
dc_other_hostnames=''
dc_local_interfaces='127.0.0.1'
dc_readhost='gmail.com'
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost='smtp.gmail.com::587'
CFILEMODE='644'
dc_use_split_config='true'
dc_hide_mailname='true'
dc_mailname_in_oh='true'
dc_localdelivery='mail_spool'

(note the double column in

dc_smarthost='smtp.gmail.com::587'

).

And

/etc/exim4/passwd.client

is:

#...
# Example:
### target.mail.server.example:login:password
smtp.gmail.com:name@gmail.com:pASSwor-d
gmail-smtp.l.google.com:name@gmail.com:pASSwor-d

To test that the installation is working, I try:

telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 cheffo-desktop ESMTP Exim 4.69 Sun, 01 Jun 2008 15:37:51 +0300

(just write <i>quit</i> to get out.)

The MTA now can be used by the CMS either directly (as Sendmail compatible program, as supported by eZ Publish), or via its own, non-TLS SMTP port. <b>Important</b> this configuration of Exim does not require password for sending mails.

Mail settings for eZ Publish, with Sendmail sending option:

[MailSettings]
Transport=sendmail

Mail settings for eZ Publish, with SMTP sending option:

[MailSettings]
Transport=SMTP
TransportServer=localhost:25
TransportUser=name@gmail.com
TransportPassword=
AdminEmail=name@gmail.com
EmailSender=name@gmail.com

(Note that

TransportPassword

option is empty).

Mauricio Sánchez

Friday 12 December 2008 12:28:45 pm

I posted a fix to SMTP class to support SSL

here is the post:

http://ez.no/developer/forum/install_configuration/is_ssl_supported_for_smtp/re_is_ssl_supported_for_smtp