Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: phpmailer, swiftmailer, smtp authentication, registration email sending problems

@chrishajer

Participant

You take all that code that howtogeek pasted and put it into a file called “replacebbmail.php” or something. To make php code into a bbPress plugin, it needs to have a header. The header needs to look something like this (change the values to something meaningful to you):

<?php
/*
Plugin Name: Swift Mailer
Plugin URI: http://www.example.com/ (doesn't really matter)
Description: Replace bb_mail with Swift Mailer
Author: You
Author URI: http://www.example.com/
Version: 0.1
*/

 

Then, paste the code that howtogeek showed at the end of that file. In the end, it will look something like this.

<?php
/*
Plugin Name: Swift Mailer
Plugin URI: http://www.example.com/ (doesn't really matter)
Description: Replace bb_mail with Swift Mailer
Author: You
Author URI: http://www.example.com/
Version: 0.1
*/

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();
}
}
?>

 

The name of the file does not matter really. Save that new file in bb-plugins. Now activate your new plugin in the admin section of your bbPress site.

You will need to configure it before activating it to make sure it works (setting up the path to swift mailer and setting the auth stuff if you need to.)

Skip to toolbar