Swiftmailer向发件人发送邮件

时间:2013-07-04 11:09:56

标签: php swiftmailer

如何防止swiftmailer将邮件发送到发送te邮件的地址?

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/www/wordpress/wp-config.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/www/wordpress/wp-load.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/www/wordpress/wp-includes/wp-db.php';

global $wpdb;

$wpdb->show_errors = TRUE;
$wpdb->suppress_errors = FALSE;

$transport = Swift_SmtpTransport::newInstance('smtp.live.com', 587, 'tls')
->setAuthMode('login')
->setUsername('hotmailaddress@hotmail.com')
->setPassword('**********');

$mailer = Swift_Mailer::newInstance($transport);

$subscribers = $wpdb->get_results( 
$wpdb->prepare(

"SELECT * FROM 
            wp_nwsbrf_subscribers 
                INNER JOIN 
                    wp_nwsbrf_couple
                        INNER JOIN 
                            wp_nwsbrf_categories
                                INNER JOIN
                                    wp_posts
                                        INNER JOIN
                                            wp_nwsbrf_subscribers_categorie
                                                WHERE
                                                wp_nwsbrf_subscribers_categorie.category_id = wp_nwsbrf_categories.category_id
                                                AND
                                                wp_nwsbrf_subscribers_categorie.subscriber_id = wp_nwsbrf_subscribers.subscriber_id
                                                AND 
                                                wp_nwsbrf_couple.category_id = wp_nwsbrf_categories.category_id
                                                AND
                                                wp_posts.ID = wp_nwsbrf_couple.ID
                                                AND
                                                wp_nwsbrf_couple.ID = %d", $_GET['postid']) );

if($wpdb->num_rows == 0)
{
    echo 'Er zijn geen abonnees';
}
else
{

    $arr = array();

    foreach ($subscribers as $subscriber) {

        $arr[] = $subscriber->subscriber_mail;
        $title = $subscriber->post_title;
        $message = $subscriber->post_content;

        $message = Swift_Message::newInstance($title)
        ->setFrom( array('hotmailaddress@hotmail.com'=>'Nieuwsbrief BV') )
        ->setTo( $arr )
        ->setBody($message);

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

    }

    echo 'Verzonden naar alle aangemelde abonnees!';
    var_dump($arr);
}

  ?>

因此,每当我向其收件人发送电子邮件时,swiftmailer也会向发件人发送相同的电子邮件。我该如何解决这个问题?

0 个答案:

没有答案