使用PHP Swift Mailer显示内部服务器错误时发送超过300封电子邮件时出错

时间:2014-04-08 12:24:12

标签: php swiftmailer mailer

使用PHP Swift Mailer发送超过300封电子邮件时出错显示内部服务器错误,只收到300封邮件

我正在使用ftp冲浪者

另一个问题是在发送200封邮件到一个小时之后邮件没有显示我们发送但是我再也没有收到任何邮件一小时后他们正在收到

邮件ID来自mysql数据库

使用每个循环邮件正在发送

        <?php    // Create the message

                                      // Create the message
                $message = Swift_Message::newInstance();


                $sql=mysql_query("select * from test_email where status=''");
                while($row=mysql_fetch_array($sql))
                {



                // Usually you want to replace the following static array
                // with a dynamic one built retrieving users from the database
                $users = array(
                  array(
                    "fullname" => "Aurelio De Rosa",
                    "operations" => $row['sno'],
                    "email" => $row['email']
                  )
                );

                // Create the replacements array
                $replacements = array();
                foreach ($users as $user) {
                  $replacements[$user["email"]] = array (

                    "{fullname}" => $user["fullname"],
                    "{transactions}" => $user["operations"]
                  );
                }

                // Create the mail transport configuration
                $transport = Swift_MailTransport::newInstance();

                // Create an instance of the plugin and register it
                $plugin = new Swift_Plugins_DecoratorPlugin($replacements);
                $mailer = Swift_Mailer::newInstance($transport);
                $mailer->registerPlugin($plugin);

                // Create the message
                $message = Swift_Message::newInstance();
                $message->setSubject("This email is sent using Swift Mailer");

                // Create your file contents in the normal way, but don't write them to disk




                // Create your file contents in the normal way, but don't write 
            //them to disk

                $type = $message->getHeaders()->get('Content-Type');

                $type->setValue('text/html');
                $type->setParameter('charset', 'utf-8');


                // Use AntiFlood to re-connect after 100 emails
                $mailer->registerPlugin(new Swift_Plugins_AntiFloodPlugin(100));

                // And specify a time in seconds to pause for (30 secs)
                $mailer->registerPlugin(new Swift_Plugins_AntiFloodPlugin(100, 30));

                // Create the message
                $message = Swift_Message::newInstance('My subject');

                // Set the body
                $message->setBody(
                '<html>' .
                ' <head></head>' .
                ' <body>' .
                '  Here is an image <img src="http://www.graymatter8.info/Developer1/swiftm/x.php?ts={transactions}&&ip='.$ip.'" alt="" width="1" height="1" border="0"/>' .
                '  Rest of message' .
                ' </body>' .
                '</html>',
                  'text/html' // Mark the content-type as HTML
                );



                $message->setFrom("account@bank.com", "Testing");
                $failedRecipients = array();
                $numSent = 0;



                // Send the email
                foreach($users as $user) 
                {
                  $message->setTo($user["email"], $user["fullname"]);

                   $mailer->send($message);

                }
            ?>

1 个答案:

答案 0 :(得分:0)

您应该以数据包形式发送,例如10-20。一旦完成一个包,你可以转到下一个10-20,依此类推......