Files
archived-web-master/include/mailer.php
Nikita Popov 369ff2016a Try adding Reply-To header to commit mails
Not sure whether this will get stripped by the mailing list, but
let's try it. I don't want to specify the author/committer email
in From, as it'll likely run afoul of DMARC.
2021-04-02 22:43:57 +02:00

40 lines
992 B
PHP

<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
class MailAddress {
public $email;
public $name;
public function __construct($email, $name = '') {
$this->email = $email;
$this->name = $name;
}
public static function noReply($name = '') {
return new self('noreply@php.net', $name);
}
}
function mailer($to, $subject, $body, MailAddress $from, array $replyTos = []) {
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 0;
$mail->Host = 'mailout.php.net';
$mail->Port = 25;
$mail->CharSet = 'utf-8';
foreach ($replyTos as $replyTo) {
$mail->addReplyTo($replyTo->email, $replyTo->name);
}
$mail->setFrom($from->email, $from->name);
$mail->addAddress($to);
$mail->Subject = $subject;
$mail->Body = $body;
$mail_sent = $mail->send();
}