Manual talk:$wgSMTP

From MediaWiki.org
Jump to: navigation, search

Contents

[edit] 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

163:     $headers['From'] = $from->toString();
164:     $headers['Return-Path'] = $from->toString();

Change to:

163:     $headers['From'] = $from->toString();
164:     $headers['Return-Path'] = $from->address;


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 will be in 1.19.

[edit] 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.

[edit] 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

[edit] 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:

$wgSMTP = array (
   'IDHost' => 'mywikidomainname.com', //this is used to build the Message-ID mail header
   'host'   => 'mail.bellsouth.net', //this is the outgoing mail server name (SMTP server)
   'port'   => 25, //this is the port used by the SMTP server
   'auth'   => false,  //in my case, authentication is not required by the mail server for outgoing mail
);

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

[edit] Another example

$wgSMTP = array(
                'host'     => "smtp.lifesci.dundee.ac.uk",
                'IDHost'   => "www.division.university.ac.uk",
                #'port'     => 25,
                'auth'     => false,
                #'username' => "my_user_name",
                #'password' => "my_password"
                );

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

[edit] 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:

$wgSMTP = array(
 "host" => 'smtp.example.com', 
 "IDHost" => 'example.com', 
 "localhost" => 'mywiki.example.com',
 "port" => "25",
 "auth" => true/false,
 "username" => user,
 "password" => password
);


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)

[edit] 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?  — Mike.lifeguard | @meta 18:32, 9 October 2009 (UTC)

[edit] 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:


     $wgSMTP = array(
        'host' => 'ssl://smtp.gmail.com',
        'IDHost' => 'mydomain.com',
        'port' => 465,
        'username' => 'webmaster@mydomain.com', ## or info@mydomain.com, or whatever email account you've set up for your Mediawiki installation
        'password' => 'emailpasswordforwebmaster',
        'auth' => true
     );

[edit] 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.

[edit] 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?


[edit] 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|C) 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|C) 05:57, 22 July 2011 (UTC)
Try running
pear upgrade MAIL Net_SMTP
Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox