How to send email via MyBB using fsockopen and GMail
Posted by Vincent Isles at Saturday, March 15, 2008MyBB is one of the best bulletin board software out there, and is the first choice in 110MB.com's 1-Click Installer page. However, the current version requires the PHP mail() function, which most hosting providers disable because of security concerns.
For 30 posts at the 110MB Forum, you can have fsockopen() enabled for your free account. Combined with a GMail account, fsockopen() will allow you to send out emails via MyBB without requiring mail(). Here is the procedure:
1. Download PHPMailer class and extract class.phpmailer.php, class.smtp.php, and language/phpmailer.lang-en.php
2. Upload the three files you extracted to the include directory of your forum (yourforum/inc/)
3. Modify the yourforum/inc/functions.php file: Find the functiona named my_mail and replace the content with the following:
function my_mail($to, $subject, $message, $from="", $charset="", $headers="")
{
require_once("class.phpmailer.php");
require_once("class.smtp.php");
global $db, $mybb;
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port
$mail->Username = "you@gmail.com"; // GMail username (including @gmail.com)
$mail->Password = "********"; // GMail password
$mail->From = "you@gmail.com";
$mail->FromName = $mybb->settings['bbname'];
$mail->Subject = $subject;
$mail->Body = $message;
$mail->AddAddress($to, "");
if(!$mail->Send())
echo "There has been a mail error sending to ".$to." with Error: ".$mail->ErrorInfo;
$mail->ClearAddresses();
}
Labels: customizing mybb, gmail and mybb, mybb, smtp in mybb

