我在wordpress上有一个已经配置好的类phpmailer的插件。php通过SMTP发送电子邮件。我的主机只接受SMTP电子邮件。当我在wordpress中注册时,我会收到一封电子邮件,当我联系另一个用户时,他会收到电子邮件。这没关系。
但当我尝试使用这个插件时,他没有发送任何电子邮件。你能帮帮我吗?提前谢谢你
<?php
ini_set(\'display_errors\',true);
ini_set(\'memory_limit\', \'128M\');
require dirname(__FILE__).\'/../../../wp-config.php\';
$db = new PDO (\'mysql:host=\'.DB_HOST.\';dbname=\'.DB_NAME, DB_USER, DB_PASSWORD);
function update_date_format(){
$lang = substr($_SERVER[\'HTTP_ACCEPT_LANGUAGE\'], 0, 2);
if (strpos($lang, \'pt\') > 0){
$date_format = \'d/m/Y\'; // 25/12/2011
}else{
$date_format = \'d/m/Y\'; // 12/25/2011
}
update_option(\'date_format\',$date_format);
}
// get config
$site_url = get_option (\'siteurl\');
$from = get_option (\'admin_email\');
$blog_name = get_option (\'blogname\');
$logo = get_option (\'cp_logo\');
$date_format = get_option (\'date_format\');
$link_edit = $site_url.\'/\'.get_option (\'cp_edit_item_url\').\'/?aid=\';
$subject = get_option (\'adsstatsemail_subject\');
$header = get_option (\'adsstatsemail_header\');
$footer = get_option (\'adsstatsemail_footer\');
$campaign = \'utm_source=Weekly%20Ads%20Stats&utm_medium=email&utm_campaign=\'.urlencode(get_option (\'adsstatsemail_campaign\'));
$ad_title = get_option (\'adsstatsemail_adtitle\');
$ad_week = get_option (\'adsstatsemail_adweek\');
$ad_total = get_option (\'adsstatsemail_adtotal\');
$ad_expire = get_option (\'adsstatsemail_adexpire\');
$ad_edit = get_option (\'adsstatsemail_adedit\');
update_date_format();
$week_start = time()-(86400*6);
// replace macros
$header = str_replace ("\\n\\n", "<br/>", $header);
$header = str_replace (\'{date_from}\', date($date_format, $week_start), $header);
$header = str_replace (\'{today}\', date($date_format), $header);
$header = str_replace (\'{site_link}\', "<a href=\\"{$site_url}?{$campaign}\\">{$site_url}</a></p><br>", $header);
$header = str_replace (\'{site_logo}\', "<a href=\\"{$site_url}?{$campaign}\\"><img src=\\"{$logo}\\" border=\\"0\\"/></a></p><br>", $header);
$footer = str_replace ("\\n\\n", "<br/>", $footer);
$footer = str_replace (\'{date_from}\', date($date_format, $week_start), $footer);
$footer = str_replace (\'{today}\', date($date_format), $footer);
$footer = str_replace (\'{site_link}\', "<a href=\\"{$site_url}?{$campaign}\\">{$site_url}</a>", $footer);
$footer = str_replace (\'{site_logo}\', "<a href=\\"{$site_url}?{$campaign}\\"><img src=\\"{$logo}\\" border=\\"0\\"/></a>", $footer);
// fetch ad info
$sql = "
SELECT
p.ID,
p.post_title,
p.post_date,
pm.meta_value AS expireDate,
u.user_email,
u.display_name,
t.postcount AS total,
SUM(d.postcount) AS week
FROM
wp_posts as p
INNER JOIN wp_postmeta AS pm ON p.ID=pm.post_id AND pm.meta_key = \'cp_sys_expire_date\'
INNER JOIN wp_users AS u ON u.ID=p.post_author
INNER JOIN wp_cp_ad_pop_total AS t ON t.postnum=p.ID
INNER JOIN wp_cp_ad_pop_daily AS d ON d.postnum=p.ID AND d.time >= DATE_SUB(NOW(), INTERVAL 1 WEEK)
WHERE
p.post_type = \'ad_listing\'
GROUP BY p.ID
ORDER BY u.ID
";
$sth = $db->query ($sql);
$list = array ();
while ($row = $sth->fetch (PDO::FETCH_ASSOC)) {
// remove expired ads
if (strtotime($row[\'expireDate\']) <= $week_start) {
continue;
}
$mail = $row[\'user_email\'];
unset ($row[\'user_email\']);
$list[$mail][] = $row;
}
// prepend header
$header = "
<html>
<head>
<meta http-equiv=\\"content-type\\" content=\\"text/html; charset=utf-8\\"/>
</head>
<body>
{$header}
<table>
<tr>
<td><b><font face=\\"Arial\\" size=\\"2\\">{$ad_title}</font></b></td>
<td><b><font face=\\"Arial\\" size=\\"2\\">{$ad_week}</font></b> </td>
<td><b><font face=\\"Arial\\" size=\\"2\\">{$ad_total}</font></b> </td>
<td><b><font face=\\"Arial\\" size=\\"2\\">{$ad_expire}</font></b></td>
<td></td>
</tr>";
// footer
$footer = "
</table>
{$footer}
</body>
</html>";
$count = 0;
foreach ($list as $email => $ads) {
$html = $header;
foreach ($ads as $ad) {
$ad[\'expireDate\'] = date($date_format, strtotime ($ad[\'expireDate\']));
$ad[\'post_title\'] = utf8_encode($ad[\'post_title\']);
$html .= "
<tr>
<td><font face=\\"Arial\\" size=\\"2\\">{$ad[\'post_title\']} </font></td>
<td><font face=\\"Arial\\" size=\\"2\\">{$ad[\'week\']}</font></td>
<td><font face=\\"Arial\\" size=\\"2\\">{$ad[\'total\']}</font></td>
<td nowrap><font face=\\"Arial\\" size=\\"2\\">{$ad[\'expireDate\']}</font></td>
<td nowrap><font face=\\"Arial\\" size=\\"2\\"><a href=\\"{$link_edit}{$ad[\'ID\']}&{$campaign}\\" target=\\"_blank\\">{$ad_edit}</a></font></td>
</tr>";
}
$html .= $footer;
$headers = "From: {$blog_name} <{$from}>\\r\\nMIME-Version: 1.0\\r\\nContent-type: text/html; charset=utf-8\\r\\n";
mail ("{$ad[\'display_name\']} <$email>", $subject, $html, $headers);
echo "$email\\n";
$count++;
}
echo "\\nDone ($count emails).\\n\\n";