知道你是否你们帮我一点点,因为我用PHP邮件瞎搞,我已经修改这个代码,但是从这里http://www.askapache.com/php/phpfreaks-eric-rosebrocks-phpmailer-tutorial.htmlPHP梅勒发送简讯
发送单封电子邮件是通过PHP邮件工作正常(与一个不同的脚本),但现在试图发送到多个电子邮件与数据库下面的脚本目前不工作..你能发现它有什么问题吗?虽然我想知道它是否真的用数据库中的电子邮件做任何事情..我有点困惑。
脚本不会成功并打印的名字,但不发送任何电子邮件了!至少没有收到..(不是垃圾邮件)任何帮助?对不起,如果这是非常明显的!
<?php
// Grab our config settings
require_once($_SERVER['DOCUMENT_ROOT'].'/mail/config.php');
// Grab the FreakMailer class
require_once($_SERVER['DOCUMENT_ROOT'].'/mail/lib/MailClass.inc');
//set execution time limit to 5 minutes
$safeMode = (@ini_get("safe_mode") == 'On' || @ini_get("safe_mode") === 1) ? TRUE : FALSE;
if ($safeMode === FALSE) {
set_time_limit(300); // Sets maximum execution time to 5 minutes (300 seconds)
// ini_set("max_execution_time", "300"); // this does the same as "set_time_limit(300)"
}
echo "max_execution_time " . ini_get('max_execution_time') . "<br>";
//db connection
$con = mysql_connect("xx","xx","xx");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("xx", $con);
// Setup body
$textBody = "Dear {MEMBER_NAME},\n\nTEST";
$htmlBody = "Dear {MEMBER_NAME},<br /><br />TEST";
// instantiate the class
$mailer = new FreakMailer();
// Get the user's Email
$sql = mysql_query("SELECT displayname,email FROM engine4_users2")or die(mysql_error());
//lets reset the time limit of the server everytime an email is sent to bypass maximum
while (1==1) {
set_time_limit(30); // sets (or resets) maximum execution time to 30 seconds)
// .... put code to process in here
while($row = mysql_fetch_object($sql))
{
// Send the emails in this loop.
$member_name = $row->displayname;
if($row->MailType == 'html')
{
$mailer->Body = str_replace('{MEMBER_NAME}', $member_name, $htmlBody);
$mailer->IsHTML(true);
$mailer->AltBody = str_replace('{MEMBER_NAME}', $member_name, $textBody);
}
else
{
$mailer->Body = str_replace('{MEMBER_NAME}', $member_name, $textBody);
$mailer->isHTML(false);
}
$mailer->Send();
$mailer->ClearAddresses();
$mailer->ClearAttachments();
$mailer->IsHTML(false);
echo "Mail sent to: " . $member_name . "<br />";
}
usleep(1000000); // sleep for 1 million micro seconds - will not work with Windows servers/PHP4
// sleep(1); // sleep for 1 seconds (use with Windows servers/PHP4
if (1!=1) {
break;
}
}
?>
的目的是什么,以你上次'if'命令? 'if(1!= 1)'?你是否重新定义了其他地方的号码? – 2012-07-06 00:08:30