bcc несколько адресов с помощью swiftmailer


Я использую приведенный ниже php-код для отправки электронного письма на один адрес и на 2 других адреса bcc. Он отправляет получателю штраф, но я могу отправить его только на один из 2 адресов bcc. (смотрите комментарии в коде для того, что я пробовал)

Как ни странно, $result возвращается как 3, поэтому кажется, что он пытается отправить второе электронное письмо bcc, но оно так и не приходит.

<?php


    $tracker='[email protected]';
    $subject = $_POST['subject'];
    $sender = $_POST['sender'];
    $toEmail=$_POST['toEmail'];
    $passedInEmail=stripslashes($_POST['message']);
    $passedInEmail=preg_replace('/&nbsp;/',' ',$passedInEmail);

    require_once('swiftLib/simple_html_dom.php');
    require_once('swiftLib/swift_required.php');
    $transport = Swift_MailTransport::newInstance();
    $mailer = Swift_Mailer::newInstance($transport);
    // Create the message
    $message = Swift_Message::newInstance();
    //turn the meesage into an object using simple_html_dom
    //so we can iterate through and embed each image
    $content = str_get_html($passedInEmail);

    // Retrieve all img src tags and replace them with embedded images
    foreach($content->find('img') as $e) 
        {
            if($e->src != "") 
                {
                    $value = $e->src;
                    $newValue = $message->embed(Swift_Image::fromPath($value)); 
                    $e->src = $newValue;
                }
        }

    $message->setSubject($subject);
    $message->setFrom($sender);
    $message->setTo($toEmail);



    //this is my problem
    $message->setBcc(array('[email protected]',$sender));
    //as it is above only "sender" gets the email

    //if I change it like this:

    //$message->setBcc($tracker,$sender);
    //only "tracker" gets the email


    //same if I change it like this:
    //$message->setBcc($sender);
//$message->addBcc($tracker);

    $message->setReplyTo(array('[email protected]'));
    $message->setBody($content,'text/html');


    $result = $mailer->send($message);
    if ($result=3) {
        echo 'Email Sent!';
    } 
    else {
       echo 'Error!';
    }
?>

Как правильно это сделать?

Author: DelightedD0D, 2013-10-02

2 answers

Вы можете найти учебник по swiftmailer здесь

Пример:

$message->setBcc(array(array('[email protected]' => 'The Name'),array('[email protected]' => 'Another Name'));

Попробуйте задать имена для адресов электронной почты и посмотрите, имеет ли это какое-либо значение.

 6
Author: Michael Thompson, 2013-10-02 16:47:26

В итоге это оказалось проблемой на стороне сервера, я связался со своим хостинг-провайдером (GoDaddy), который смог внести некоторые изменения со своей стороны, решив проблему. Спасибо всем, кто пытался помочь!

 0
Author: DelightedD0D, 2013-10-05 05:36:37