Categories
Package/plugin/module WordPress

Plugin: wpPHPMailer

This plugin has been deprecated! It is no longer being developed and there will not be any continued support for it. Comments to this post are also now closed.

Fear not, for the essence of the plugin continues on in my Configure SMTP plugin.

Name:
wpPHPMailer
Author:
Scott Reilly
Version:
1.6
Last updated:
29 July 2005
Description:
Enable WordPress to send e-mail via SMTP instead of via PHP’s mail() function (aka sendmail).

Notes:

Since I didn’t want to install and run sendmail merely to support WordPress’s notifications, I opted to have WordPress send directly to the mail server. Fortunately, PHPMailer provides all the functionality I wanted to use (and more). This plugin makes use of PHPMailer (and one slight core code change) to negate the need for sendmail. In addition, by using PHPMailer a host of other mail features could be exploited. For instance, the plugin supports:

  • Auto-wordwrap length for message
  • Single or multiple SMTP servers
  • Hard-coding of all notification origination e-mail addresses (i.e. have all e-mail “From:” fields set to something like “gro.etisymnull@sserpdrow” rather than the e-mail of the commenter)
  • Support for authenticating and non-authenticating SMTP servers
  • HTML in addition to plaintext ContentTypes for the message body

Special note for upgraders: If you are upgrading from a version of this plugin prior to 1.5 you will have to make note of the settings you had previously set in the wp-phpmailer.php file and re-enter them via the plugin’s new admin options page.

Installation:
  1. Unzip/unpack the plugin distribution file wp-phpmailer.zip into your wp-content/plugins/ directory.

    [Unless you wish to alternatively install the full PHPMailer yourself, then instead do this:

    1. Obtain the PHPMailer package from phpmailer.sourceforge.net
    2. Extract the contents into your wp-content/plugins/ directory (this should create a subdirectory called something like ‘phpmailer-1.72’
    3. Rename the directory created in (b.) to ‘wp-phpmailer’

    NOTE: This plugin was last tested against PHPMailer version 1.72. The plugin distribution file only contains the English-language file for PHPMailer; many other language files are available from the official PHPMailer distribution

  2. [Skip this step unless you chose to install PHPMailer yourself]
    Copy the file wp-phpmailer.php from the plugin distribution file into your wp-content/plugins/wp-phpmailer/ directory
  3. Activate the plugin from your WordPress admin ‘Plugins’ page.
  4. In WordPress’s Admin section, click the Options tab. Then click the “wpPHPMailer” subtab. Adjust the configuration options to suit your situation. Be sure to change the very first option, which tells WP to use wpPHPMailer instead of the built-in mailer.

    NOTE: If you are using WP 1.5.1 or later, you do not have to do anything else. Just be aware that you cannot have more than one plugin activated that attempts to override the core WP function, wp_mail(). If you activate this plugin and do not see the “wpPHPMailer” tab under “Options” in the Admin section, then you *may* have mail plugin conflicts.

  5. For those using a version of WP prior to 1.5.1 : In the WordPress core file wp-includes/functions.php, find and replace the single occurrence of “function wp_mail(” with “function old_wp_mail(“
Functions:

function wp_mail($user, $subject, $message, $headers, $htmlmessage='')

This is a helper function that retrieves the URL of the image for a specified category. Returns ” if no image was found:

  • $user : The user sending the e-mail (i.e. user@host.org; “Some Guy” <user@host.org>)
  • $subject : The e-mail Subject:
  • $message : The e-mail message body, of the ContentType “text/plain” variety
  • $headers : (optional) Custom e-mail headers; default is ”
  • $htmlmessage : (optional) If defined, then the e-mail will be sent with mixed ContentTypes, a “text/html” part using $htmlmessage and an alternate “text/plain” part using $message.
Tips & Examples:

N/A

Related Links:
Release Log:
  • 29 July 2005 : v1.6 released (long delayed) — Now takes advantage of the pluggability of wp_mail() in WP 1.5.1+ so that NO core file editing is necessary to utilize this plugin; also, potentially fixed a pathname problem that occurred on Windows servers
  • 02 Apr 2005 : v1.5 released —
    • Added option page for plugin in WP’s admin section
    • Options now stored in the WP database and no longer in the plugin’s file
    • Instructions updated to pertain to WordPress v1.5
    • License changed from BSD-New to MIT
  • 17 Aug 2004 : v1.01 released — Slight fix to header handling so “From:” isn’t duplicated
  • 16 Aug 2004 : v1.0 released — Now fully compliant as drop-in replacement for mail():
    • $headers argument defaulted to ”
    • if $headers is not defined, then no choice but to use hardcoded From: values; if $headers is defined and $use_hardcoded_FROM_values is true, try to set the Reply-To: field to be header From: value (if defined)
    • defaults hardcoded e-mail address as the admin’s e-mail address; defaults From: name as “Blog Admin”
  • 27 Jul 2004 : v0.93 released — now returns boolean value to indicate success (true) or failure (false) of the mailing; a minor tweak; documentation change at the top of the file to reflect item noted in 13 Jul update. (Thanks, Will!)
  • 13 Jul 2004 : Updated documentation to reflect the need to change “mail()” call to “phpmailer()” in wp-login.php for password retrieval.
  • 11 Jul 2004 : v0.92 released — slight fix due to the boolean setting $use_hardcoded_FROM_values being used with opposite logic. Also left hardcoded From: fields uncommented (they aren’t used unless the aforementioned setting is set ‘true’. (Thanks again, Ricardo!)
  • 09 Jul 2004 : v0.91 released — fix so that root@localhost doesn’t appear as the From: field (Thanks, Ricardo!)
  • 28 Jun 2004 : v0.9 released to the public
Copyright & Disclaimer:

Copyright (c) 2004-2005 by Scott Reilly (aka coffee2code)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Acknowledgements:
I’d like to thank the PHPMailer team for creating the package this plugin merely wraps.

127 replies on “Plugin: wpPHPMailer”

I installed this pluging in my “especiales” section (click on “enviar”) and it worded well after some shape adjustments. But my web is in Spanish and all the special character get messed in the email. The person receives a lot of weird characters in the post content. It´s look like the system takes the UT8-code directly but not its “value”.
If the web were in English this pluging would work perfect.
Does anyone know how to fix this problem?
Thanks

Im having trouble even getting this to work, i need it for regristration and for people who wish to send me a comment, ive tested both and have never recieved anything

I used the prebuilt version, and tried SMPT server provided by Gmail and 1and1, neither want to work, the plugin is enabled ofcorse

anychance someone can contact me for some help, thanks 🙂

[…] Version 2.1.6 also switches mail delivery from PHP’s mail() function to the WordPress wrapper function wp_mail(). For most people, this will not result in any change whatsoever to the functioning of my plugin. But for those struggling with mail delivery issues, they can use Scott Reilly’s excellent wpPHPmailer plugin, which allows WordPress to speak SMTP directly to a mail server, instead of using the server’s sendmail command-line utility for mail delivery. I have tested subscribe2 with wpPHPmailer, and can confirm that it works quite well (at least for me!). RSS feed for comments on this post. TrackBack URI […]

Great plugin! It’d be cool though to have either a “test” button (to attempt to login to the SMTP server) or a form to fill out that sends a test e-mail all via the options page so that I know it’s working.

I am getting this warning, can anyone help me out. I am just trying to register a user, and I am not getting site updates either.

Warning: fsockopen(): unable to connect to smtp.comcast.net:25 in /home/content/t/r/e/trentstrek/html/blog/wp-content/plugins/wp-phpmailer/class.smtp.php on line 105

Thanks,
C

Getting a Warning: fsockopen() [function.fsockopen]: php_hostconnect: connect failed in F:\hshome\cstjohn9\mydogsblog.com\blog\wp-content\plugins\class.smtp.php on line 105 and then Warning: fsockopen() [function.fsockopen]: unable to connect to :25 in F:\hshome\cstjohn9\mydogsblog.com\blog\wp-content\plugins\class.smtp.php on line 105
ERROR
not getting a connection to any smtp servers, i’ve tried a few, the local one for the website, gmail. I’ve tried a couple port #, but i thought 25 was the default.
Any ideas?

Great plug-in, thank you! The standard mail() function just doesn’t work on my ISP’s configuration. In the previous version of WordPress I was using I hacked the old function to make it use SMTP instead, this was a much simpler solution now I’ve upgraded to 1.5

Cheers!

I’ve got a very strange problem.
I can only send email to my own adress (gmail)
I’ve tried registering more gmail adresses and sending to them doesn’t work. You would think that this problem would lie with my SMTP server but changing the servers doesn’t solve my problem either. Anyone?

wpPHPMailer

I am finally receiving emails when somebody posts a comment in the blog thanks to Scott Reilly and his wpPHPMailer plugin for WordPress. Instead of trying to send the notification email through sendmail, this plugin allows for an SMTP server…yay…

Hello,
First of all, great plugin. Very useful for people who keep there webservers and email servers seperate. But I had a suggestion… some plugins send email to multiple recipients, such as subscribe2. It would be nice for your plugin to allow multiple recipients. I made a modification to your plugin that allowed the wp-mail function to be sent multiple addresses in the $user variable…
line 151 after the ClearAllRecipients statement of wp-phpmailer.php

 
if ( $user &gt; 1 ) {
                foreach($user as $currentuser) {
                        $currentuser = trim($currentuser);
                        if (! empty($currentuser)){
                                $mail-&gt;AddAddress($currentuser);
                        }
                }
        } else {
                $mail-&gt;AddAddress($user);
        }

Maybe there is a better way of doing it, but just a suggestion…
Thanks again,
Kyle

Just got WP 2.0 up and running on Windows 2003 and using IIS SMTP with the phpmailer and the plugin. Works great, but have the issue of no “From” address in the e-mails going out, eventhough I set one in the Admin page.. Is there a quick hack to hardcode this the right place??

Thanks much!

Hi, I’m running WordPress 2.0.1-alpha. Suddenly, tonight, my comment emailing plugin (Subscribe2) broke with this error when trying to post a comment:

Warning: fsockopen(): unable to connect to mail.tatumweb.com:25 in /home/tatumweb/public_html/blog/wp-content/plugins/wp-phpmailer/class.smtp.php on line 105

Warning: fsockopen(): unable to connect to tatumweb.com:25 in /home/tatumweb/public_html/blog/wp-content/plugins/wp-phpmailer/class.smtp.php on line 105

Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/tatumweb/public_html/blog/wp-content/plugins/wp-phpmailer/class.smtp.php on line 105

Warning: fsockopen(): unable to connect to smtp.tatumweb.com:25 in /home/tatumweb/public_html/blog/wp-content/plugins/wp-phpmailer/class.smtp.php on line 105

Warning: Cannot modify header information – headers already sent by (output started at /home/tatumweb/public_html/blog/wp-content/plugins/wp-phpmailer/class.smtp.php:105) in /home/tatumweb/public_html/blog/wp-includes/pluggable-functions.php on line 194

Any ideas? My SMTP server didn’t change.

Regards,

Rich
BlogRodent

Nevermind. I poked around and realized that my ISP is blocking unauthenticated posts via port 25. Nothing I could do would authenticate, so I checked some more and found that I needed to use a totally different port for authentication. Now it works. Thanks, and sorry for the blather.

Rich

Hello,

Whatever I do, I am still getting this error:
================
Warning: fsockopen(): unable to connect to mail.bellsouth.net:25 in /home/content/g/a/r/garym/html/wordpress/wp-content/plugins/class.smtp.php on line 105

Registration Complete
Username: testagain
Password: emailed to you
E-mail: ten.htuosllebnull@tset

Login »

=================

I input the smtp settings that I use in my Outlook to send outgoing mail.

Help, please!
Thanks a lot.
Gary

hello, i follow the setup but i can’t active this plugin. i can’t find the wp-phpmailer under admin panel -> option.

my server is windows 2003 web edition, iis6, php 4. did anyone got this plugin work with windows server?

I have been having so much trouble trying to figure out why my comments weren’t being forwarded to me… well you plugin fixed it for me. Thanks. Also thanks to the wordpress message board who sent me here, Here’s to getting problems fixed.

cheers,

Peter
www.lublink.ca

I did it as you say,but it still can’t work and disply like below:
Parse error: parse error, unexpected T_ARRAY, expecting T_STRING in /home/vhosts/moneytalk.hf4l.com/blog/wp-content/plugins/wp-phpmailer/class.smtp.php on line 576

Can somebody update this or take this project over? We would really like to see this plugin updated to work with WordPress 2.0+ installations.

I get this error:
PHP Warning: fsockopen(): unable to connect to :25 in C:\hshome\jeginer\golfblog.es\blog\wp-content\plugins\phpmailer\class.smtp.php on line 105

Any ideas?

Thanks

I was able to download and install this in about 5 minutes. I’ve only tested it with password reset emails and it seems to be working great! The hardest part was figuring out my ISP SMTP server 🙂 I really didn’t want to run sendmail just for blog notifications.

Thanks for the great plugin.

This works great, excxept for one problem I was having in combination with the Subscribe2 plugin.

With hardcoded From email not checked, I was sending out subscription emails with a blank From: header. I traced it down to this (line 136 in wp-phpmailer.php):

preg_match('|From: \"([^"]*)\" ]*)&gt;|', $headers, $fromfields);

To get it working, I changed the regex to:

preg_match('|From: \"?([^"]*)&gt;|', $headers, $fromfields);

Note I made surrounding quotes around the sender name optional.

I’ve only tested this on my install, I don’t know how robust this regex is.

I’ve tried everything but am still getting no emails.
I have WordPress 2.04 installed on a Win2k server running IIS. The server is on a DMZ along with our Linux email servers.
I have installed wpPHPMailer no problem.
I have activated and configured it no problem.
I have used the internal IP address of the SMTP email server (although I have also tried it by name)
I want people to be able to register themselves.
Wordpress says registration has been successful and a password has been emailed but nothing arrives.
Where can I check to see what is going wrong?

For those of you getting this error:

Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed:

I had the same thing – just had my SMTP settings incorrect. You may want to check the same thing.

I am also getting the error:
Warning: fsockopen() [function.fsockopen]: unable to connect to pilotswap.net:25 (An established connection was aborted by the software in your host machine. ) in D:\WWW\pilotswap\wp-content\plugins\wp-phpmailer\class.smtp.php on line 105

It WAS working until 10 Sept when Comcast decided to plug the hole I was using. As it turns out, I AM able to send mail from my client using SSL and port 465. I am not, however, smart enough to modify this plugin enough to make it use ssl and secure authentication.

Has ANYONE done this yet? Can this be easily done? I am (unfortunately) dead in the water without a way to mail new user passwords and password reminders.

Thanks in advance
Pete

Hi!

I’m using wp-phpmail with wp-contactform.
But I’m still getting:

“wp-content\plugins\wp-contact-form\wp-contactform.php on line 146”

Which point out to:
mail($recipient, $subject, $fullmsg, $headers);

I don’t think wordpress recognizes change under “Mail handler:” under Options.

Any ideas?

Sorry. The warning was:

Warning: mail(): Failed to connect to mailserver at “localhost” port 25, verify your “SMTP” and “smtp_port” setting in php.ini or use ini_set() in C:\…..\wp-content\plugins\wp-contact-form\wp-contactform.php on line 146

@manne: In my poking around, I’ve found that WP-ContactForm does not support the usage of wpPHPMailer by default.

To add support for wpPHPMailer to the WP-ContactForm plugin, open wp-contactform.php and change line 146 [ mail($recipient, $subject, $fullmsg, $headers); ] to the following:

wp_mail($recipient, $subject, $fullmsg, $headers);

I’ve installed this plugin with wordpress v. 2.0.5 and I’m not able to send mail at all. I’d also like to get this plugin to work with the wp-member plugin.

Any help?

Installed and enabled (do i need to enter/change values in the wp-phpmailer.php
e.g.
$mail->IsSMTP(); // set mailer to use SMTP

$mail->Host = $options[‘Host’];
$mail->SMTPAuth = $options[‘SMTPAuth’] ? $options[‘SMTPAuth’] : true;
if ($mail->SMTPAuth) {
$mail->Username = $options[‘Username’];
$mail->Password = $options[‘Password’];

file if so… not very clear in the installation instructions

Comments are closed.