Unable to get SMTP 6.2 for Drupal 6 to work with GMail
| Project: | SMTP Authentication Support |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | won't fix |
Jump to:
I am using SMTP 6.2 for Drupal 6 by hafizul (taken from http://drupal.org/node/214975#comment-830810)
I have been working on this for days but I cannot seem to get SMTP to work with GMail. I am using XAMPP over Windows XP Pro and I have SSL enabled in Apache. I am using the following settings:
SMTP Server: smtp.gmail.com
SMTP Port: 465
Username: something@gmail.com
When I try to send a test e-mail it just hangs there for a while and eventually ends up with a blank page.
Apache's error logs are clean. I am stumped. I tried entering under ssl://smtp.gmail.com as the SMTP Server but when I do that I get this error:
* warning: fsockopen() expects parameter 2 to be long, string given in D:\xampp\htdocs\drupal\sites\abs-cbnnews.com\modules\custom\smtp\smtp.module on line 1979.
* warning: fsockopen() [function.fsockopen]: unable to connect to :465 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ) in D:\xampp\htdocs\drupal\sites\abs-cbnnews.com\modules\custom\smtp\smtp.module on line 1979.
* Unable to send e-mail. Please contact the site admin, if the problem persists.

#1
Hmmm ... I realized I did not have openssl enabled in PHP so I enabled it. I was still getting errors and I thought somehow the SMTP module does not select SSL. So I added the ff line (in bold) to force the module to use the SSL protocol.
//Set the correct protocol prefix to append to the smtp host.
switch(variable_get('smtp_protocol', 'standard')) {
case "ssl":
$mail->Protocol = 'ssl://';
break;
case "tls":
$mail->Protocol = 'tls://';
break;
case "standard":
$mail->Protocol = '';
}
<strong> $mail->Protocol = 'ssl://';</strong>
$mail->Host = variable_get('smtp_host', '') . ';' . variable_get('smtp_hostbackup', '');
$mail->Port = variable_get('smtp_port', '25');
$mail->Mailer = "smtp";
$mail->SMTPAuth = $auth;
$mail->Username = $username;
$mail->Password = $password;
$mail->CharSet = 'utf-8';
I found that a few lines before there is supposed to be a selection list for choosing the correct protocol, but it checks if the openssl_open function exists:
if (function_exists('openssl_open')){ //Only display the option if openssl is installed.$form['server']['smtp_protocol'] = array(
'#type' => 'select',
'#title' => t('Use encrypted protocol'),
'#default_value' => variable_get('smtp_protocol', 'standard'),
'#options' => array('standard' => t('No'), 'ssl' => t('Use SSL'), 'tls' => t('Use TLS')),
'#description' => t('This allows connection to an SMTP server that requires SSL encryption such as gmail.'));
So apparently I am missing that function because I do not have the SSL module installed or enabled. Where can I get the OpenSSL module for Drupal?
#2
First off, there is no official 6.x release of the SMTP Authentication Support module, so you're not going to get support for what you have installed in this issue queue.
Secondly, there is no OpenSSL Drupal module. You need to install the openssl software on your server, and then make sure your webserver and your installation of PHP have support for openssl included in them.