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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 16:14:22
Script start
Timing: Jan 18 2025 16:14:22
Module start 'layout'
Timing: Jan 18 2025 16:14:22
Module start 'content'
Timing: Jan 18 2025 16:14:23
Module end 'content'
Timing: Jan 18 2025 16:14:23
Script end

Main resources:

Total runtime0.6116 sec
Peak memory usage4,096.0000 KB
Database Queries62

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0055 589.5938152.6563
Module start 'layout' 0.00550.0025 742.250039.4922
Module start 'content' 0.00790.6021 781.7422609.7031
Module end 'content' 0.61010.0015 1,391.445316.1250
Script end 0.6116  1,407.5703 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.5238160.0002
Check MTime0.00130.2057160.0001
Mysql Total
Database connection0.00090.141310.0009
Mysqli_queries0.552090.2552620.0089
Looping result0.00060.0924600.0000
Template Total0.582995.320.2914
Template load0.00190.315420.0010
Template processing0.580994.981620.2905
Template load and register function0.00020.031910.0002
states
state_id_array0.00150.238910.0015
state_identifier_array0.00080.131020.0004
Override
Cache load0.00170.2770560.0000
Sytem overhead
Fetch class attribute can translate value0.00050.084430.0002
Fetch class attribute name0.00100.165250.0002
XML
Image XML parsing0.00070.108430.0002
class_abstraction
Instantiating content class attribute0.00000.001550.0000
General
dbfile0.00070.1140160.0000
String conversion0.00000.001140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
21content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
15content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 46
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs