[wp-hackers] Adding phpmailer options (smtp for example)

Peter Westwood peter.westwood at ftwr.co.uk
Thu Aug 30 16:23:11 GMT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Callum Macdonald wrote:
> Ok, I've whipped up a plugin. It's a copy of the original wp_mail()
> function but it adds SMTP by default (to localhost) and a couple of
> other config options. They're currently only configurable within the
> file itself, but if it's a popular plugin I'll be happy to add an
> Options page to make it easier to configure.
> 
> Any feedback would be much appreciated.
> http://www.callum-macdonald.com/code/wp-mail-smtp/

Nice plugin.

But it misses on the simplicity of the task in hand.

This is actually all you need:

<?php
/*
 * Plugin Name: pjw-wp-mail-smtp
 * Version: 0.1
 * Plugin URI: http://blog.ftwr.co.uk/wordpress/
 * Description: Get PHPMailer to use smtp not mail()
 * Author: Peter Westwood
 * Author URI: http://blog.ftwr.co.uk/
 * */

add_action('phpmailer_init','pjw_phpmailer_init');

function pjw_phpmailer_init($php_mailer)
{
    $php_mailer->Mailer = 'smtp';
    $php_mailer->Host = 'localhost';
}
?>

The hook phpmailer_init is called just before ->Send in trunk and you
can just override the few parameters and not have to replace the whole
of wp_mail.

Hope this helps.

westi
- --
Peter Westwood
http://blog.ftwr.co.uk
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG1u7vVPRdzag0AcURAsAbAJ9HV4dCyIuruiUe+btA1TlPTAPV4gCeIh7Q
UyRxCo3v2hAi+Pw7i/5hi7s=
=NjUf
-----END PGP SIGNATURE-----


More information about the wp-hackers mailing list