33 lines
823 B
PHP
33 lines
823 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Orrisroot\Mail;
|
|
|
|
class UTF8_Mailer
|
|
{
|
|
/**
|
|
* send mail.
|
|
*
|
|
* @param Address $form from email address
|
|
* @param array $tos to email addresses
|
|
* @param string $subject subject
|
|
* @param string $body mail body
|
|
*
|
|
* @return bool false if failure
|
|
*/
|
|
public static function sendMail(Address $from, array $tos, string $subject, string $body): bool
|
|
{
|
|
$mailer = new \PHPMailer\PHPMailer\PHPMailer();
|
|
$mailer->CharSet = 'UTF-8';
|
|
$mailer->setFrom($from->getEmail(), $from->getName());
|
|
$mailer->Subject = $subject;
|
|
$mailer->Body = $body;
|
|
foreach ($tos as $to) {
|
|
$mailer->AddAddress($to->getEmail(), $to->getName());
|
|
}
|
|
|
|
return $mailer->Send();
|
|
}
|
|
}
|