Configuring an SMTP server for sending mail with Drupal

Sending mails from Drupal is a feature we take for granted. Sometimes however you can't rely on the default SMTP settings available from your hosting provider. This week I was unable to send mails from my Drupal site, because the default sendmail installation was no longer functioning. Fortunately I quickly found a solution with the SMTP Authentication Support module.Typically the default SMTP settings are buried in a file named "php.ini". PHP usually comes with a wrapper to the sendmail application. Sometimes the SMTP settings for PHP are crippled or deactivated on purpose, e.g. on shared hosting plans. If you're not in control of your server, then you can't edit this file.
No sending mails for you from Drupal then? Not necessarily.
The SMTP Authentication Support module builds on top of the SMTP library from PHP Mailer. When installed, it will substitute itself to the default mail send API. The basic features of this module are:

  • Configuration of a primary and optionally a secondary SMTP server
  • Support for SMTP authentication (optional)
  • Support for SSL encryption (optional)
  • Configuration of sender's email address and name (defaulting to the site name)
  • Debug messages and test email (with configurable recipient's address) for checking whether the SMTP configuration is functional

Installation is a 5 step procedure:

  1. Download and unpack the the SMTP Authentication Support module: it will unpack in an "smtp" directory.
  2. Download and unpack the PHP Mailer module that corresponds to your needs (I downloaded the PHP 5/6 version).
  3. Rename the PHP Mailer directory (mine was "PHPMailer_v5.1") to "phpmailer" and drop it into the "smtp" directory (see step 1).
  4. Upload the "smtp" directory to your host's "sites/all/modules" directory.
  5. Enable the SMTP Authentication Support module (browse as Drupal admin to admin/build/modules)

Now all that remains, is to configure the SMTP Authentication Support module:

  1. Browse as Drupal admin to admin/settings/smtp
  2. Turn the module on {#emotions_dlg.grin}
  3. Specify the SMTP server you want to use. Optionally, specify a backup SMTP server. Check with your hosting provider (or ISP) for the settings that apply to you.
  4. Configure the SMTP connection settings: specify an alternate SMTP port, authentication (optional), whether an SSL connection should be initiated.
  5. Configure the sender's identity: email address and sender's name (the latter defaults to the name of your Drupal site).
  6. Fill in a valid email address in the "Send test email" field to test your configuration. Please do so, in order to test your setup!
  7. Click "Save configuration" and you are done!

If you see PHP errors on a white background, you probably either forgot to upload the PHP Mailer library, or you did not rename its directory to "phpmailer" (all lowercase!), or this directory is in the wrong location. These errors won't break your Drupal site - they only appear when you try sending a mail.

Nemo's picture

hey thanx...I followd the

hey thanx...I followd the your steps n I done...!!!!!!

Ran's picture


Servers now days drop all emails that do not show where the server email comes from, because this is what spamers use. This is why drupal emails might of worked in the past. Anyone on a shared host now needs to do this step. Godaddy's is ""

Pete's picture

Although a little out of date, you saved me a LOT of frustration

I have a D7 install and SMTP Authentication Support module not come with PHPMailer.
See author's comments:
We have a new functional release for D7. Lot's of clean-ups on code have been made, and PHPMailer is now being shipped with it, so it works out-of-the-box. Go test this now!
Thanks very much!!!

Piyush's picture

thanks buddy

Thanks a lot. It worked for me.

KP's picture

unable to configure it in comapny account

I tried all above steps..but unable to sentd successfull test mail.     I have got my company domain mail id which is directed on Gmail .
my smtp server setting is --  ,  port 465 (Please correct me if i m wrong)
use encryption protocol- NO
smtp authentication-- nothing i have put...what should i use if required ?
sender identity -- (my company mail id)
test maild id-- some other personal id
after saving takes long time and after that it shows --smtp module is active...but there is no test mail...
pls help me in solving this problem where company domain id is used and its already directed to google mail.

Nemo's picture

You need SSL for gmail

You need SSL for gmail

Nemo's picture

thanks a lot!

thanks a lot!

Abhi's picture

Thank you! for your help.

Recently there was a huge delay in sending out email inquiries from our client sites and they were literally getting emails after 10-15 hrs after submission from website. Due to the delays they were losing out on business. Thanks for your help. It solved the issue.

Felix's picture

doesn't seem to work for me

I've done all the above, but i didn't recieve any email.  Here's my config my files:
I've try both PHPmailer and SMTP.  Current config are: PHPMailer:
Primary SMTP:
Backup SMTP: blank
SMTP Port: 465
Secure Protocal: SSL
SMTP Authenication - Username:
Advanced Setting - 
From Name: forum
check box - keep connection alive
Debug Level:  Full Communication Selected
When I test the Configuration- it said: A test email has been sent to  When I check there's no email.
What did I do wrong?  I used Ubuntu 10.04 apache2.
thank you

Olivier Biot's picture

Re: doesn't seem to work for me

Hi Felix,
I tried it on my system (I couldn't cooect to Gmail's SMTP server either) and came to the conclusion that the most obvious reason for failure is that the ports used by Gmail's SMTP server are blocked by my (and probably your) hosting provider.
Incidentally, I realized that I had PHP Mailer 5 installed on my box, while the SMTP Authentication Support module only supports PHP Mailer versions up to version 2.2.1.
On my current hosting provider ( the secure SMTP ports used by Gmail are not accessible (ports 465 for SSL and 587 for TLS), probably for security reasons (spam).
Best is to check with your ISP (or hosting provider) which SMTP relay you are allowed to (or must) use. Try first with your ISP's SMTP server settings and leaving the "E-mail options" fields empty. Then, if that works, try filling in the "E-mail From address" field and send again a test message (check box at the bottom of the configuration page for the SMTP Authentication module).
Hope this helps!

NJ's picture

SMTP Error

I followed all the above step but still I am not able to send email.
I am using Drupal 6.25 and when I put my gmail id for testing, it says:
Sending of at least one e-mail failed. The error returned was:SMTP error: could not connect to SMTP host. Unable to send e-mail. Please contact the site administrator if the problem persists. 
In my phpinfo() the OpenSSL support is shown to be diabled. I do have a php_openssl.dll file in my xampp/php/ext directory but there is no mention of extension=php_openssl.dll line in my php.ini.
So I copy pasted extension=php_openssl.dll line in my php.ini file and restarted the xampp server, but still I get the above error and not able to send any mail.
Does anyone have a solution for this problem.

Olivier Biot's picture

Re: SMTP Error

Since you're mentioning XAMPP, make sure you can access the SMTP server from your box. Sometimes firewalls and virus scanners block certain resources (I know I could not send mails or run the web server on port 80 on a couple laptops where I am a restricted user).
In addition I know that several hosting providers disable access to 3rd party SMTP servers as a measure to prevent spam. It looks like you're trying to access the Gmail SMTP server, which is not always accessible. Can you access another SMTP server?
Best regards,

alex's picture

Thanks!!! :)

Dear Oliver,
You are the best! I really appreciate your help
Dear Felix, maybe you must check the "Authenication" which means the password of your
Far away from Chile,

Nemo's picture


Thanks a lot for such great instructions!!! Jordan

Santiago Rojas's picture

SMTP problems

Hi, i installed and configures SMTP module and works fine, but the problem accurs when Drupal send email notification to new users. Why?

Karmraj's picture

Issue to send mail using trigger rule with smtp module

I  have install  smtp module  with phpmailer lib. its working fine. but when i trying to send an email using trigger rules on my specific node creation throw an error link "Unable to send an email please contact to site administrator".
Please give any suggestion to achive this thing.
Karmraj Zala

Munique's picture

SMTP problems

Hey man,
Thanks A LOT. I had a lot of trouble before finding this tutorial and now everything is running smothly.

parbat's picture

drupal smtp problem ?

hello, frnd
drupal smtp emailer can work contact me if not work on skype : linuxwebhost
i will help you but before contact me you can include mail.php funtion in your module then it will work

vaishali's picture

Thanks for the article. I

Thanks for the article. I follow all the steps but this didnt work for me. SMTP module works on my localhost, but when I tried on server it gives me error " Unable To Send Email. Contact Sites Administrator".

Alexander Doni's picture

I Love you!!!!!!!

Thank you very much man!!!!!!!!!!!

I only want to say something that can help others. I have Drupal 6 on my site and had probelm with mails. Followed this guide but still something was wrong. Anyway with this smtp module now the error was on the log of drupal and on status report. In fact in my case it didn't find php mailer libraries and it specifically ask to put the folder phpmailer in sites/all/libraries
If folder doesn't exist just create it :)

Thank you again!!!

Naren's picture

Thanks for the article..!

Thanks a lot, It's worked good for me..!

Govind Totla's picture


Works for me. Thanks a ton.

Rianti's picture

Thank you

Thanks for the post. sending email does take delay on share hosting environment. And these delays can make people think that their emails are not sent.

mp3 songs's picture

thank you

Thanks a lot it's working fine for me tooo....... great :)

Nemo's picture

This helped me so much. thank

This helped me so much. thank you.

calochito's picture


Great help!

uhoney's picture


Your advise specifically regarding the PHPMailer solved my problem sending mail out from my Drupal site....thank you!

Qamaruddin's picture


The detailed steps helped us to configure sending email.
Thanks a lot.

Nemo's picture

it worked!!!

tanx a lot man... luv yo.. :P

amrsji's picture

It worked!

Hey your tutorial was awesome!
You were right about the phpmailer module. it really helped! Thumbs up! Smile

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account associated with the e-mail address you provide, it will be used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.