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
- 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:
<br /> $wgSMTP = array(<br /> 'host' => "mail.example.com", //could also be an IP address<br /> 'IDHost' => "example.com",<br /> 'port' => 25,<br /> 'auth' => true,<br /> 'username' => "my_user_name",<br /> 'password' => "my_password"<br /> );<br />
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!