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.

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


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.

  1. Unzip/unpack the plugin distribution file 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
    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(“

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.; “Some Guy” <>)
  • $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:


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.


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

127 replies on “Plugin: wpPHPMailer”

I installed your plugin and it’s working for almost everything. The only problem I’m having is that it won’t send lost password requests out. Instead, if gives the message “The email could not be sent.
Possible reason: your host may have disabled the mail() function…”

I searched wp-login.php for the @mail function, but didn’t see anything.


Thanks for the catch! In wp-login.php, the calls you want to look for are “mail(” (and not “@mail(“). There should be 2; replace them with “phpmailer(” and you should be set. I’ve updated the documentation above to reflect this additional change.

Hrmm.. I changed both of them, but it’s still giving me the same error.

Does the plugin only version of phpmailer report back to the app if the message successfully sends?

The weird thing is that the messages are actually sending, and it seems to be changing the password in the database, but the new passwords don’t work. Don’t test this with your main admin account for your WP blog.

If the mail actually got through to you, then that’s about as far as this plugin will get you. On the forums I’ve seen various posts about password problems. Not sure if they are in any way related to your problem or not. But if you received the e-mail about the password change, I wouldn’t think the bad password issue would arise from your use of this plugin to e-mail you your password. I could be wrong; but it doesn’t seem likely, unless the plugin were garbling the contents of the e-mails, which I haven’t witnessed myself.

It looks like the wp-login script is calling the mail() function and expecting a true response if the message sent successfully. I’m just going to change that part of wp-login and hardcode it to send me a message and tell the user that I’ll change the pw asap.

Anyway, thanks for putting this together. It really kicks ass for those of us goofy enough to host their sites on Win2k.

A comment made in another post that is more appropriate here.

Marcello said:

Hi Scott, I’ve found your site after a (pityful) search in WP forum, ’cause I was looking for a mail script working with WP; it isn’t yet clear to me if it is a user or admin post. I mean, it allows any surfers to post to me, or the contrary?
Second; it wille enbed its callers in the index page, or when I click the “mail” link, I’ll be brought to another page? I mean, as you know, wp works with the loop sequence; will your script affect the index page’s contents, or will be called independently?

In my precedent layout, I build this form (it worked with cgi) to avoid nasties:
I made hidden the msg and subject boxes (with a default writings in them) and let visible only the email field; a user had to click only 4 buttons to write in the hidden subject (with document-write.ubjectbox) field the motivation of the contact, then added the mail, and had to wait for my reply… if the subject choice were likely to my expectative (job, site, infos; no complains)
I might sugest you an improvement to avoid smuts, no-spam and other mechanisms; a cookie checker to allow users to contact the admin only once (or twice, or more, as far as the admin has setted in the config) per day. silly people will desist.

This plugin could be used to send mail to users, or for web-based forms for users to e-mail you. However, it would merely be the mechanism that performs the actual e-mailing. You would be the one responsible for creating and formatting the input form in a web page, ensuring that you query all the necessary information from the user, validating the information they provide, and then passing the appropriate arguments to the phpmailer() function.

Provided you do all that (which is sounds you already do some of it), then you’d just need to make the function call (with a argument for proper headers). You don’t necessarily have to modify index.php, but you’ll need to make a page somewhere for the actual form. Then it’s up to you to create a “You web-mail has been sent” page.

You’d also have to do the cookie-check and anti-smut comment cleansing, as this plugin doesn’t do anything but properly wrap the content for e-mailing.

In short, you’d still have some work cut out for you, but at least you would have the ee-mailing aspect covered.

Plugin updated to v0.93

I updated the plugin so that phpmailer() returns a boolean to reflect whether sending the e-mail was successful (true) or failed (false). This addresses Will’s final problem from above.

This is the error I get when I try to get a new password mailed to me… I also don’t get any other notifications… the fourth argument is that of headers I think… but I am completely clueless on this… do I have to contact my web sapce provider for this… I think it’s a windows server… could that be a problem? though it has php 4.3….please help…

Warning: Missing argument 4 for phpmailer() in d:\public\henna\blog\wp-content\plugins\wp-phpmailer.php on line 69

The email could not be sent.
Possible reason: your host may have disabled the phpmailer() function…

I am also getting the same error as henna

I try to reset the password of a user, to test, and I get the ‘argument 4’ warning and the email received to the users email address has a blank user name and the random password… But, I can still login with the previous password for that user…

Warning: Missing argument 4 for phpmailer() in c:\inetpub\wwwroot\wp-content\plugins\wp-phpmailer.php on line 69

The email was sent successfully to 's email address.
Click here to login!

Warning: Missing argument 4 for phpmailer() in c:\inetpub\wwwroot\wp-content\plugins\wp-phpmailer.php on line 69

Plugin updated to v1.0

This release addresses an issue that didn’t quite make the function a drop-in replacement for mail(). That particuar issue was the cause of henna‘s problems, and after suggesting a fix, she tested and verified it worked. That change, and a few others, have been incorporated into this release.

(I had actually worked the issue out with her a few days ago, but I intended to try to incorporate some other tweaks before making a new release, which is why I haven’t appeared to have followed up on the matter until now.)

Let me know if any problems arise, as this release as a whole was fairly hot off the presses.

i’m having trouble finding the changes that i need to make here:

a.) Replace all occurrences of “@mail” with “@phpmailer” in the following files:

wp-admin/users.php (1 change)
wp-includes/functions.php (2 changes)
wp-register.php (1 change)

b.) Replace occurrences of “mail(” with “phpmailer(” in wp-login.php (2 changes)

has this been changed in WP 1.5? i can only find 1 change in functions.php, the rest don’t exist.

john: Yeah, the instructions have changed since WP 1.2. For WP 1.5, there is just one place in functions.php where you need to make the change from “@mail(” to “@phpmailer”. In the coming week I plan on updating this plugin with the latest instructions and some trivial tweaks. For the most part you’ll be fine with what is available now.

This is probably a dumb question: what did I miss if the emails that are being sent are missing both the from: name and email address?

I’ve tested v1.5 with WP-1.5. The generated mails are a bit broken:

There are two From headers. One is empty, the other has the expected address. The empty one seems to come from phpmailer because the Return-Path is just <> (ie. class.smtp.php didn’t provide an address for the MAIL FROM command).

Content-Type also shows up twice. Once with charset UTF-8 (from WP), and once with iso-8859-1 (from phpmailer).
phpmailer also sets a Content-Transfer-Encoding header. That’s good but it clashes with one of the Content-Type headers (8bit is OK for iso-8859-1 but not UTF-8).
(Strangely, vanilla WP doesn’t encode the subject and body and doesn’t set a Content-Transfer-Encoding header. Makes me wonder how it wants to handle UTF-8 stuff outside the ASCII range)

MIME-Version: 1.0 shows up twice too.

Having the same problem as jrees & chris. After installing the plugin (Windows 2003 server), clicking on options-> wpPHPMailer fails. The link appends the fully qualified server path to wp-phpmailer.php to the wp-admin url, like so:\wp-phpmailer.php

What should this url be?

I’ve tried to directly access the file wp-phpmailer.php, but i get the following error:
“Fatal error: Call to undefined function: is_plugin_page() in E:\Inetpub\\wp-content\plugins\wp-phpmailer.php on line 69”

Please help.



I get “No input file specified” on mine when I try hitting the admin link for the mailer. I’m running Windows 2000 Advanced Server and php 4 with mySQL. The rest of the blog works fine.

Is there something I should be doing differently?

Anyone with problems accessing the Options page for the wpPHPMailer plugin and willing to try a one-line change:

Locate this line, on line #144:

add_options_page('wpPHPMailer Options', 'wpPHPMailer', 8, __FILE__); //, 'c2c_admin_phpmailer

Change it to this:

add_options_page('wpPHPMailer Options', 'wpPHPMailer', 8, 'wp-phpmailer/'.basename(__FILE__)); //, 'c2c_admin_phpmailer

Does that help?

Hi. I’v installed your script, and changed @mail with @phpmailer in the functions file, but when i try to make it send me my password it still tells me “The e-mail could not be sent. Possible reason: your host may have disabled the mail() function…” What have i done wrong?

I’m getting the arrors below. It works, I’ve posted a comment and it’s mailed me, but you can see an error strin on my blog, in the dashboard, and when you submit a comment. What to do?

Warning: open_basedir restriction in effect. File is in wrong directory in /home/httpd/vhosts/ on line 67

Warning: Cannot add header information - headers already sent by (output started at /home/httpd/vhosts/ in /home/httpd/vhosts/ on line 6

Warning: Cannot add header information - headers already sent by (output started at /home/httpd/vhosts/ in /home/httpd/vhosts/ on line 7

Warning: Cannot add header information - headers already sent by (output started at /home/httpd/vhosts/ in /home/httpd/vhosts/ on line 8

Warning: Cannot add header information - headers already sent by (output started at /home/httpd/vhosts/ in /home/httpd/vhosts/ on line 9



This has been fixed with
The thing to note is, the mail function is no longer in wp-includes/functions.php but is now in wp-includes/pluggable-functions.php.

It works most excellently with the new blog code. I’ll update my other blogs now and be happy 🙂

Thanks for an excellent plugin!

i can’t get this to work. i use wordpress, and i’ve changed the following file: wp-includes/pluggable-functions.php

line 68 has been changed to the following:

return @phpmailer($to, $subject, $message, $headers);

this line is the only one which contains the syntax «@mail(»

(let me just use a couple of lines to give a little rant on how frustrating it is that the documentation doesn’t reflect the current file name)

i’ve changed options in wp to use «SMTP via wpPHPMailer» and added a valid SMTP-server, and saved the changes. however, the SMTP server does not get an SMTP call from wp when someone tries to use the e-mail function.

when trying to register a new user, the session hangs for ~15 seconds before it displays the default text:

# Registration Complete
# Username: fsi83wb
# Password: emailed to you
# E-mail: moc.liamenull@ym
# Login »

when trying to retrive a forgotten password, this happenes:

# The e-mail could not be sent.
# Possible reason: your host may have disabled the mail() function…

in both cases, there isn’t any attempted connections towards the SMTP server.

what am i doing wrong?

Don`t touch the wp core code anymore.
Just activate the functions using the pluggable functions.

just change te code of wp-phpmailer.php to add a function like this.

function wp_mail ($to, $subject, $message, $headers = '') {
  return phpmailer( $to,  $subject, $message, $headers='') ; 

In this way you can upgrade without break anything .

greetings work very well

I Scott,
I followed your installatoin procedure but I could’t find the “@mail” occurence in the file wp-includes/functions.php (see step 5).
I installed wordpress 1.5.1 (italian localized version) on Apache for win.
Have you some suggestion?
Thanks in advance

My ISP tells me:
– – – – –
the php mail() function has been disabled on your hosting plan

If you wish to send mail using your WordPress site, you may need to adjust the settings for the form mailer to include the SMTP Relay for your email address.
– – – – –
Is this what this plugin does?
I’ve installed it using the latest suggestions, pluggable-functions, but I still get the “mail() is disabled” error when I try to retrieve my password.

Just setting this in the wp-phpmailer.php wasn’t enough:

function wp_mail ($to, $subject, $message, $headers = '') {
  return phpmailer( $to,  $subject, $message, $headers='') ;

I also went in an made the original wp_mail in pluggable-funtions.php a comment (rather than remove completely) and it works like a charm!

Hmmm, I’m still having a problem with the install.

I updated wp-phpmailer.php to include function wp_mail, but that was unsuccessful. I then commented out wp_mail in pluggable-functions, and that didn’t help either.

I’m at a bit of a loss – can anyone provide some insight?

Found a spelling mistake bug in the most recent version:
Line 128 of wp-phpmailer.php
$mail-&gt;WordWrap = $options['WordWrap'] ? $optiosn['WordWrap'] : 60;
should be

  $mail-&gt;WordWrap = $options['WordWrap'] ? $options['WordWrap'] : 60;

Not sure how I found that.

So I guess I’m confused by your instructions. You say there is no other changes that need to be made after activating the plugin with the most recent release, but do certain edits need to be done in order to receive forgotten password emails, or new registration emails?

With the default install, I am not able to receive emails via your plugin. I’ll keep messing with it, but I appreciate any assistance. Thank you in advance.

Nevermind, figured it out. I know, I know, why the h@ll did you post your question so quickly, well, I don’t know. I jumped the gun.

If your server is already setup for relay, don’t use authentication. Unchecked and worked perfectly.

Thanks again,


The email notification plugin does not appear to send mail. I’m using phpmailer. I’ve tried changing all mail( to phpmailer( in the notification directory under plugins, but no go.

Has anyone else using phpmailer gotten the email notification plugin to work, and what did you do?

Hello and Thank you for a great plugin first of all. I’ve got the April version of wpphpmailer running just fine. When I tried to install the new version, it didn’t show up in the admin bar… No error messages though. I don’t think I use any other plugins that override wp_mail(). WP is Any idea what could cause this behaviour? Thank you in advance and regards, Florian


Firstly many thanks for your plug in, I think when I get it working its going to be excatly what I need!

I am running a windows 2003 server and am having a few problems, ie. I am still getting the The e-mail could not be sent. error.

I am using an internal smtp IP address in the set up, which I think is fine because as soon as I change it to its external alies it tell me it cant connect.

Any thoughts, could it be a firewall issue on port 25? I dont think its open but all other mail from other apps works, CDONTS for example.

Cheers and thanks for all the hard work!


Hello everyone,

My config:
wpPHPMailer v1.6
WordPress 1.5.2
Fedora Core 4

I had two big issues to overcome to make it work. Hopefully this info will help somebody.

1) I was getting the “your host may have disabled the mail() function” error.
I started digging through, and found that under the covers, the code was throwing an error along the lines of “Language string failed to load: connect_host”.
I ignored the Lang() error, and troubleshot the failed connection. Another layer deeper, I was getting a “Permission Denied (13)” on the fsockopen() call.
I had to run system-config-securitylevel, go to the SELinux tab, open the “HTTPD Service” entry, and check the box for “Allow HTTPD scripts to connect to the network.”

That got me to the next problem.
2) My error messages became something along the lines of “Authentication Request denied” or some such.
I found out that the line $mail-&gt;SMTPAuth = $options['SMTPAuth'] ? $options['SMTPAuth'] : true; always results in $mail->SMTPAuth = 1 for me, regardless of whether the Authentication box is checked in Options. So even if my smtp server doesn’t use authentication, it tries to authenticate me with blank user/pass, which fails. I changed the line to $mail-&gt;SMTPAuth = $options['SMTPAuth'] ? true : false; and it works fine.


Hmm, code tags mangled my arrows… for clarification, I changed wp-phpmailer.php wp_mail() from

$mail->SMTPAuth = $options[‘SMTPAuth’] ? $options[‘SMTPAuth’] : true;


$mail->SMTPAuth = $options[‘SMTPAuth’] ? true : false;



I’m using WP 1.5.2. I’ve installed the plugin as the instructions said. However I always get this message when requesting a password to be e-mailed.

 The e-mail could not be sent.
Possible reason: your host may have disabled the mail() function... 

Are there any changes that need to be made for it to work with with 1.5.2 ?

Thanks for the help

Comments are closed.