Configuring MediaWiki to use external SMTP

At my new company, I setup a copy of MediaWiki and wanted to make sure that all the notifications work. One kink was that the mail needed to be sent through an external service called SendGrid. Since I setup MediaWiki and it is for internal use only, I could probably have skipped the email service but it seemed like a good exercise. Fortunately, MediaWiki has the capability to do this and it isn’t terribly difficult.

First thing you want to do is install PHP’s PEAR Mail. If you’re on Ubuntu/Debian, it’s super simple:

  • sudo -s
  • apt-get install php-pear
  • pear install mail
  • pear install Net_SMTP
  • pear install Auth_SASL
  • pear install mail_mime
  • /etc/init.d/apache2 restart

Now you need to add/configure MediaWiki’s $wgSMTP variable in your wiki’s LocalSettings.php file, an example is show here:

$wgSMTP = array(
'host' => "", //could also be an IP address
'IDHost' => "",
'port' => 25,
'auth' => true,
'username' => "my_user_name",
'password' => "my_password"

If you don’t need to authenticate yourself, change ‘auth’ to false and drop the username/password options. Otherwise you should be able to get right onto the wiki and start emailing yourself through your 3rd party mail system. If you have any issues, just set $wgShowExceptionDetails = true; in your LocalSettings.php file and try your request again. As for myself, the configuration to SendGrid (which offers a “free plan” with 200 messages a month) was painless and works flawlessly. Now I know my messages will get delivered and have DKIM and DomainKeys!

You may also like...

Leave your thoughts

%d bloggers like this: