Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: trick to fix some email problems with 0.8.x plugins on 0.9.x

I wrote my own replacement plugin for the mail function that uses the Swift Mailer PHP class to call sendmail directly, which should provide better performance over the built-in php mail functions.

It also gives the the chance to assign a display name to the email address so it comes through as “bbPress Support Forum” instead of just “forum@bbpress.org”.

if ( !function_exists('bb_mail') ) {
function bb_mail($to, $subject, $content, $headers=''){

require_once('PATH_TO/Swift/lib/Swift.php');
require_once('PATH_TO/Swift/lib/Swift/Connection/Sendmail.php');

$swift =& new Swift(new Swift_Connection_Sendmail("/usr/sbin/sendmail -bs"));
$from = new Swift_Address("noreply@mysite.com","My bbPress Forums");

$message =& new Swift_Message($subject, $content);
if ($swift->send($message, $to, $from)) {return true;}
else{ echo "Message failed to send to ".$to." from ".$from;}
$swift->disconnect();
}
}

To use this, you’d have to download Swift from their site and put it where it’s included in the above code.

http://www.swiftmailer.org/

You could also modify it to connect to an external SMTP server (even the Gmail server, for instance) by changing the Swift_Connection part above using this guide:

http://www.swiftmailer.org/wikidocs/v3/connections/smtp

Skip to toolbar