mirror of
https://github.com/php/web-master.git
synced 2026-03-24 15:52:09 +01:00
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.
40 lines
992 B
PHP
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();
|
|
}
|