Skip to content

Commit

Permalink
Merge pull request #3058 from BOINC/dpa_email
Browse files Browse the repository at this point in the history
web: make it possible to send HTML email
  • Loading branch information
TheAspens authored May 13, 2019
2 parents a7caf86 + 83f7abd commit 3670e7c
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions html/inc/email.inc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function send_email($user, $subject, $body, $body_html=null, $email_addr=null) {
if ($body_html) {
$mail->AltBody = $body;
$mail->Body = $body_html;
$mail->IsHTML(true);
} else {
$mail->Body = $body;
}
Expand All @@ -63,11 +64,16 @@ function send_email($user, $subject, $body, $body_html=null, $email_addr=null) {
} else if (defined('EMAIL_FROM')) {
$headers = "From: ". EMAIL_FROM;
}
if ($email_addr) {
return mail($email_addr, $subject, $body, $headers);
} else {
return mail($user->email_addr, $subject, $body, $headers);
if (!$email_addr) {
$email_addr = $user->email_addr;
}
if ($body_html) {
$body = "<html><body>\n";
$body .= $body_html;
$body .= "\n</body></html>\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
}
return mail($email_addr, $subject, $body, $headers);
}
}

Expand Down Expand Up @@ -179,7 +185,12 @@ function salted_key($key) {
return md5($key.'oogabooga');
}

function opt_out_url($user) {
return secure_url_base()."opt_out.php?code=".salted_key($user->authenticator)."&userid=$user->id";
function opt_out_url($user, $page="opt_out.php") {
return sprintf("%s%s?code=%s&userid=%d",
secure_url_base(),
$page,
salted_key($user->authenticator),
$user->id
);
}
?>

0 comments on commit 3670e7c

Please sign in to comment.