发送到多个电子邮件swiftmail php

时间:2019-09-23 07:49:48

标签: php email swiftmailer

  

未捕获到的Swift_RfcComplianceException:给定[angga.q.suwito@gmail.com','stand.last41@gmail.com','gamingid41@gmail.com”的邮箱中的地址不符合RFC 2822、3.6.2。在C:\ xampp \ htdocs \ test \ swiftmailer \ vendor \ swiftmailer \ swiftmailer \ lib \ classes \ Swift \ Mime \ Headers \ MailboxHeader.php:355堆栈跟踪:#0 C:\ xampp \ htdocs \ test \ swiftmailer \ vendor \ swiftmailer \ swiftmailer \ lib \ classes \ Swift \ Mime \ Headers \ MailboxHeader.php(272):Swift_Mime_Headers_MailboxHeader-> assertValidAddress('angga.q.suwito @ ...')#1 C:\ xampp \ htdocs \ test \ swiftmailer \ vendor \ swiftmailer \ swiftmailer \ lib \ classes \ Swift \ Mime \ Headers \ MailboxHeader.php(117):Swift_Mime_Headers_MailboxHeader-> normalizeMailboxes(Array)#2 C:\ xampp \ htdocs \ test \ swiftmailer \ vendor \ swiftmailer \ s \ lib \ classes \ Swift \ Mime \ Headers \ MailboxHeader.php(74):Swift_Mime_Headers_MailboxHeader-> setNameAddresses(Array)#3 C:\ xampp \ htdocs \ test \ swiftmailer \ vendor \ swiftmailer \ swiftmailer \ lib \ classes \ Swift \ Mime \ SimpleHeaderFactory.php(61):C:\ xampp \ htdocs \ test \ swiftmailer \ vendor \ swiftmailer \ swiftmailer \ lib \ classes \ Swift \ Mime \ Headers \ MailboxHeader.php中的Swift_Mime_Headers_MailboxHeader-> s

>
<?php

require_once 'swiftmailer/vendor/autoload.php';

$email[] = 'angga.q.suwito@gmail.com';
$email[] = 'stand.last41@gmail.com';
$email[] = 'gamingid41@gmail.com';

$semuaemail = implode("', '",$email); 

$transport = new Swift_SmtpTransport('smtp.gmail.com', 465, 'ssl');
$transport->setUsername('gamingid41@gmail.com')->setPassword('56865681');

$mailer = new Swift_Mailer($transport);

$message = new Swift_Message('Weekly Hours');
$message
   ->setFrom(['gamingid41@gmail.com' => 'My Name'])
   ->setTo([$semuaemail => 'Recipient'])
   ->setSubject('Coba dang sejadi')
   ->setBody('bukan kaleng kaleng', 'text/html');

$result = $mailer->send($message);

echo "Berhasil terkirim";

?>

0 个答案:

没有答案