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

Thanks

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 "relay-hosting.secureserver.net"

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

Hi
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 .  xxx@mycompanydomain.com
my smtp server setting is -- smtp.gmail.com  ,  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 -- xxx@mycompanydomain.com (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.
thanks

Nemo's picture

You need SSL for gmail

You need SSL for gmail

Nemo's picture

thanks a lot!

thanks a lot!

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.