mirror of https://github.com/BOINC/boinc.git
web: update interface to PHPMailer
Depending on your mail server, PHPMailer can take various config options. Instead of passings these as variables from project.inc to email.inc, have project project.inc define a function make_php_mailer() that creates a PHPMailer object, configures it as needed, and returns it. For projects that use PHPMailer, this will require modifying your project.inc.
This commit is contained in:
parent
f8ee2e51fe
commit
5d0b06136a
|
@ -25,24 +25,12 @@ require_once("../project/project.inc");
|
||||||
$config = get_config();
|
$config = get_config();
|
||||||
$master_url = parse_config($config, "<master_url>");
|
$master_url = parse_config($config, "<master_url>");
|
||||||
|
|
||||||
// Determine if phpmailer is installed and to be used (defined in project.inc)
|
|
||||||
if (isset($USE_PHPMAILER)) {
|
|
||||||
if ($USE_PHPMAILER) {
|
|
||||||
require_once("../inc/phpmailer/class.phpmailer.php");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$USE_PHPMAILER = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// send an email, using PHPMailer or not.
|
// send an email, using PHPMailer or not.
|
||||||
//
|
//
|
||||||
function send_email($user, $subject, $body, $body_html=null) {
|
function send_email($user, $subject, $body, $body_html=null) {
|
||||||
global $USE_PHPMAILER;
|
if (function_exists("make_php_mailer")) {
|
||||||
global $PHPMAILER_HOST;
|
require_once("../inc/phpmailer/class.phpmailer.php");
|
||||||
global $PHPMAILER_MAILER;
|
$mail = make_php_mailer();
|
||||||
|
|
||||||
if ($USE_PHPMAILER) {
|
|
||||||
$mail = new PHPMailer();
|
|
||||||
$mail->AddAddress($user->email_addr, $user->name);
|
$mail->AddAddress($user->email_addr, $user->name);
|
||||||
$mail->Subject = $subject;
|
$mail->Subject = $subject;
|
||||||
if ($body_html) {
|
if ($body_html) {
|
||||||
|
@ -51,10 +39,6 @@ function send_email($user, $subject, $body, $body_html=null) {
|
||||||
} else {
|
} else {
|
||||||
$mail->Body = $body;
|
$mail->Body = $body;
|
||||||
}
|
}
|
||||||
$mail->From = EMAIL_FROM;
|
|
||||||
$mail->FromName = EMAIL_FROM_NAME;
|
|
||||||
$mail->Host = $PHPMAILER_HOST;
|
|
||||||
$mail->Mailer = $PHPMAILER_MAILER;
|
|
||||||
if (!$mail->Send()) {
|
if (!$mail->Send()) {
|
||||||
echo $mail->ErrorInfo;
|
echo $mail->ErrorInfo;
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -29,6 +29,33 @@ define("UOTD_ADMIN_EMAIL", "admin@$master_url");
|
||||||
// offensive forum posts.
|
// offensive forum posts.
|
||||||
define("POST_REPORT_EMAILS", "moderator1@$master_url|moderator2@$master_url");
|
define("POST_REPORT_EMAILS", "moderator1@$master_url|moderator2@$master_url");
|
||||||
|
|
||||||
|
// If you use PHPMailer, uncomment the following
|
||||||
|
// and complete the function definition based on your SMTP server
|
||||||
|
// (not all fields may be needed)
|
||||||
|
//
|
||||||
|
if (0) {
|
||||||
|
function make_php_mailer() {
|
||||||
|
$mail = new PHPMailer();
|
||||||
|
$mail->IsSMTP();
|
||||||
|
//$mail->Mailer = 'smtp';
|
||||||
|
$mail->SMTPAuth = true;
|
||||||
|
$mail->SMTPSecure = "tls";
|
||||||
|
$mail->Host = "smtp.gmail.com";
|
||||||
|
$mail->Port = 587;
|
||||||
|
$mail->Username = "john.doe@gmail.com";
|
||||||
|
$mail->Password = "xxx";
|
||||||
|
// Google's application-specific password,
|
||||||
|
// if you are using the 2-Step Verification: 16 characters, no spaces.
|
||||||
|
// OR: Put here the regular Gmail password if you are not using the
|
||||||
|
// 2-Step Verification with your Gmail account.
|
||||||
|
// See https://support.google.com/accounts/answer/185833?hl=en";
|
||||||
|
$mail->SetFrom('admin@boincproject.com', 'John Doe');
|
||||||
|
$mail->AddReplyTo("admin@boincproject.com", "John Doe");
|
||||||
|
$mail->From = "admin@boincproject.com";
|
||||||
|
return $mail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function project_banner($title, $prefix) {
|
function project_banner($title, $prefix) {
|
||||||
// Put your project title and logo here
|
// Put your project title and logo here
|
||||||
// If you include any links, prepend URL with $prefix
|
// If you include any links, prepend URL with $prefix
|
||||||
|
|
Loading…
Reference in New Issue