Manual talk:$wgSMTP

MediaWiki 1.18.0 #BUG
For those having a headache trying to get the SMTP functionality to work using MW-1.18.0 there's a little oopsy in the UserMailer.php file under /includes. It seems the PEAR parameters "From" and "Return-Path" are incorrectly populated.

Make the following changes to Line 164 in UserMailer.php to fix the problem.

ORIGINAL Change to:

Note: It appears this is fixed in the "trunk" but i'm not sure if that code is slated for 1.19 or not


 * The above is fixed in 1.18.1 and the change above is confirmed to be in 1.19beta2.

IDHost causing problems
It appears that the MediaWiki code in includes/UserMailer.php is using the IDHost property to generate the email message id (in email headers).

Please note that IDHost is not a property documented at http://pear.php.net/manual/en/package.mail.mail.factory.php making it confusing that the code would count on it being present in $wgSMTP.

I recommend that either this documentation makes a special note that IDHost should be set for MediaWiki and is not a documented option for PEAR Mail, or providing an acceptable default such as automatically detecting the domain from other $wgSMTP options or the system hostname.

Usage, this usage needs to be confirmed!
This can be used to setup access to your mail server. Say, when you have trouble sending mails you may get strange messages - like this:


 * Notice of the mail server: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Paris' for '2.0/DST' instead

(sorry for the odd way of formating this, I dont know how to do this right) (Speciel:Confirmemail) Asset

Example for Usage
I used this configuration variable to resolve a problem that I was having with my ISP's mail server refusing to forward e-mail generated by my wiki site. I am running a web server using my DSL connection, with Bellsouth as my ISP. Bellsouth's mail server was not delivering any messages generated using PHP's sendmail function -- to resolve this problem, I set up my configuraton file so that mail generated by my wiki was sent using Bellsouth's mail server.

In my case, the Bellsouth mail server does not require authentication because I am sending mail from a Bellsouth IP address. After installing PEAR's MAIL package, I included the following in my LocalSettings.php file:

Voila! No more undelivered messages! --Hoggwild5 15:21, 18 November 2008 (UTC)

Another example
--Dmb 16:16, 15 January 2009 (UTC)

Example with localhost parameter
if you are using a remote SMTP server, you may wish for the wiki to identify itself with a resolvable hostname instead of localhost. This is set in the $wgSMTP array localhost parameter:

Some mail servers will reject with "Helo command rejected: Host not found". For example postfix with smtpd_helo_restrictions = reject_unknown_helo_hostname --Erikvw 07:57, 23 January 2009 (UTC)

Does IDHost need to be changed?
The documentation isn't even clear on whether this value needs to be changed from default. If so, what should go here? &mdash; Mike.lifeguard &#124; @meta 18:32, 9 October 2009 (UTC)

Example using Google Mail
Note: this method should only be used on low-traffic wikis since Google limits the sending of emails from any single email address to 500 per day

Many ISPs are providing Google Apps as an alternative to their legacy email system. Using Google's mail servers requires additional configuration settings. If you are using Google Apps for email for your domain, there are a few additional configuration options that need to be implemented to use Google to send mail from your MediaWiki site.

First, you need to make sure your ISP has compiled PHP with OpenSSL support. You can check this with the output of phpinfo, looking to see if OpenSSL is enabled ( this is for Unix/Linux flavors -- Windows will have other installation options ).

If this is the case, you can configure MediaWiki to use Google mail to send email from your MediaWiki site.


 * Set up an email account for the MediaWiki site (webmaster@mydomain.com, or info@mydomain.com), making a note of the password assigned to this account.


 * Configure your LocalSettings.php file with the following setting, replacing "mydomain.com" with your domain name:

Customizing the "From" line
Using the Gmail option, you can configure a custom "From" line (that uses your own domain) by setting a new default address (under "Settings" -> "Accounts and Import" -> "Send mail as:"). Set $wgPasswordSender to match this new default address.

Comments
Dmitry N. Medvedev (talk) 01:58, 21 March 2012 (UTC) Does not work.
 * How so?Jasper Deng (talk) 03:34, 21 March 2012 (UTC)
 * It wrote: Failed to connect to ssl://smtp.gmail.com:465 [SMTP: Failed to connect socket: Connection timed out (code: -1, response: )] --Dipsy (talk) 13:20, 25 July 2012 (UTC)
 * Sorry, I incorrectly wrote IDHost. Everything works fine. --Dipsy (talk) 07:38, 28 July 2012 (UTC)

why PEAR?
so i installed PEAR in /wiki/PEAR. but i don't quite know what it is used for? and does it even matter where it's installed?
 * PEAR is an extension to PHP itself, not MediaWiki, so it's best to install it in PHP's directory.Jasper Deng (talk) 05:46, 21 March 2012 (UTC)

Deprecated:Assigning the return value of new by reference
"Deprecated:Assigning the return value of new by reference is deprecated in C:\xammp\PEAR\mail.php on line 154." --TDeeming 11:42, 20 July 2011 (UTC)When trying to use the mail function I get the error message above. The mail is actually sent successfully, but the error message above is displayed across the top of the screen. Can any one provide assistance?


 * Sounds like you have an old version of the PEAR Mail package. —Emufarmers(T 09:20, 21 July 2011 (UTC)
 * How can I tell what version of Pear I am using. I recently XAMMP Basis version 1.74 and it includes PHP 5.3.5 and Pear. In Pear.php is says something about version 1.104 2008/01/03... but I don't know if this is the system or the file... mail.php reads 1.18 from 2006.


 * When you see "2008" and "2006", that's a bad sign. —Emufarmers(T 05:57, 22 July 2011 (UTC)


 * Try running

Amazon SES
I just wanted to note that I was successful integrating MediaWiki with Amazon's Simple E-mail Service using this feature and SES's new SMTP support. This is important because a lot of providers block e-mail sent directly from EC2 servers, and Amazon will block the SMTP port if too many messages are sent. However, even in production mode SES restricts From addresses to previously validated addresses, so the $wgUserEmailUseReplyTo variable must be set to true to ensure user-to-user e-mail will work, and $wgEmergencyContact must be set to a validated sender address. Dcoetzee (talk) 13:13, 8 April 2012 (UTC)

Since I fought this for a couple of days, I thought I'd add my experience for the next person attempting this. From this page, I got the following config:

Of course, username and password will be the ones Amazon assigned to you, not the ones shown in the example. I also found it extremely helpful to add 'debug' => true, in there to be able to see the errors in the SMTP exchange. WARNING, setting debug will show anyone who is visting your registration page the SMTP exchange which includes the password!

While not trying to make this a SES tutorial, I would like to note that the single biggest problem I ran into was that you MUST have your SES instance configure for Production, not Sandbox. If you do not, you can't send to unregistered To: addresses. Given that the point here is to email addresses you don't know ahead of time, this is very relevant for this use case. While I was googling for this problem, I can see lots of people seemed to be confused on that point, so I thought I would note it. --Ryanlrussell (talk) 18:18, 7 April 2014 (UTC)

Using Gmail
I'm using Gmail to send mail, my configs: It doesn't work. Anyone know why? Thamdaocatba (talk) 06:09, 16 November 2012 (UTC)
 * See the section "Using Google Mail" above.--Jasper Deng (talk) 06:55, 16 November 2012 (UTC)

SELinux
If you see this error when sending email after configuring $wgSMTP, you probably have SELinux enabled.

[SMTP: Failed to connect socket: Permission denied (code: -1, response: )]

CentOS, Fedora, Red Hat, and other users may need to reconfigure SELinux to allow PHP scripts to send email. You can *test* if this is your issue by following this guide - How to Disable SELinux. If it is, re-enable SELinux, and allow httpd (Apache) to use sendmail with

Some advices
I have solved problem with this tutorial, just take care with this:

1. If you are using Gmail, ensure of aprobe access, or Gmail will detect it as malicious acces and you couln't make it work. 2. If you have a error of acces to a socket or smething like this, it's due your hosting doesn't have open port for you, so ask them to open respective port, in case of Gmail, is port 465. 3. Put code at the beggining, before extensions codes. 4. Make sure you have installed 2 scripts of php, if you have cpanel, go to php console and install them, it's too easy as I can do it.

I hope could help you.

Google rejecting automated MediaWiki messages
I am trying to get mail working using my gmail account as the outgoing address. I am using the following configuration:

$wgSMTP = array(       'host' => 'ssl://smtp.gmail.com',        'IDHost' => 'gmail.com',        'port' => 465,        'username' => ' @gmail.com',        'password' => ' ',        'auth' => true    );

All mail then gets bounced back to my gmail account with a message similar to this:

Delivery to the following recipient failed permanently: @gmail.com Technical details of permanent failure: Message rejected. See https://support.google.com/mail/answer/69585 for more information.

Any ideas on how I can fix this? Entropy (talk) 20:09, 10 May 2016 (UTC)


 * Try changing IDHost so it matches your domain. Otherwise, try something from --Ciencia Al Poder (talk) 21:59, 10 May 2016 (UTC)
 * It turns out my firewall was blocking port 465—unblocking it fixed the problem. I had to enable less secure apps for my Gmail account under Account Settings as well. Email is now working fine with IDHost set to gmail.com. Entropy (talk) 22:49, 10 May 2016 (UTC)

Problem with Hostmonster solved - should be part of the docs
Hi there, I think this should be added to the documentation. The code could also be improved to give a more helpful message. Thanks 146.198.223.71 23:30, 21 May 2016 (UTC)
 * Added to Manual:$wgEnableEmail, you may want to mention it in this page as well (I can't edit it). Thanks. 146.198.223.71 23:53, 21 May 2016 (UTC)
 * I've added it on the section about "Unknown error in PHP's mail function " --Ciencia Al Poder (talk) 12:42, 22 May 2016 (UTC)
 * Nice one, thanks. Although, to me it reads a bit backwards, because fixing the sender is a less drastic solution than going through another SMTP server, and should be tried first. Also, if I understand it correctly, the reference to task T32260 relates to possible issues with the last-resort workaround, so it should be the last line of that section. Cheers. 146.198.223.71 17:05, 22 May 2016 (UTC)
 * Ok, done --Ciencia Al Poder (talk) 01:48, 24 May 2016 (UTC)

How do I avoid exposing the server's IP address?
I'm using mailgun, with this setup: The emails contain: X-Mailgun-Sending-Ip: xxx.xx.xxx.xxx X-Mailgun-Sid: ... Received: from localhost (affiliate.test.known.host [xx.xxx.xx.xxx]) by mxa.mailgun.org with ESMTP id ... ; Tue, 27 Sep 2016 20:42:39 -0000 (UTC) How do I get it to not expose that localhost IP address? Let me tell you hwhat (talk) 00:50, 30 September 2016 (UTC)