我使用的是Joomla 1.6平台的自定义表单。用户电子邮件很好,但通知我们注册的电子邮件没有通过。是否可以像这样背靠背发送2封电子邮件,或者我的代码中是否有错误?
///----------------User Email After Registered----------------------------///
// Send notification email //
$to = $email;
$subject = "$hs2 Alumni Football Team";
$message = "
<html>
<head></head>
<body>
<h1>Alumni Football USA</h1>
<p> Hi $firstname,</p>
<p>You are now able to sign up for $hs2 games! Login to Reserve your spot!</p>
<p>Username: $username</p>
<p>Password: $showpass</p>
<p>$hs2 Alumni Football Team Page---$remail2 </p>
<p>This is an automatic Email, please do not respond/reply</p>
</body>
</html>
";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= 'From: Alumni Football USA<NOREPLY@alumnifootballusa.com>' . "\r\n";
// Send notification //
mail($to,$subject, $message, $headers);
///---------------Email site owner-----------------------------------------///
$phone1 = $cell;
$cell1 = formatPhone1($phone1);
$phone2 = $home;
$home1 = formatPhone2($phone2);
$query = "SELECT t_name FROM " . $table_prefix . "bl_teams WHERE id = ".$team_id;
$db->setQuery($query);
$hs2 = $db->loadResult();
$query = "SELECT ((date_format(now(),'%Y') - date_format(birthday,'%Y')) - (date_format(now(),'00-%m-%d') < date_format(birthday,'00-%m-%d')))
FROM " . $table_prefix . "users WHERE'".$email."' = username";
$db->setQuery($query);
$age45 = $db->loadResult();
$query = "SELECT t_city FROM " . $table_prefix . "bl_teams WHERE ".$team_id."= id ";
$db->setQuery($query);
$city5 = $db->loadResult();
$query = "SELECT s.s_descr FROM " . $table_prefix . "bl_seasons as s WHERE ".$s_id."= s.s_id ";
$db->setQuery($query);
$state = $db->loadResult();
$query = "SELECT u.email FROM " . $table_prefix . "users as u, " . $table_prefix . "bl_teamcord as tc WHERE tc.s_id = ".$s_id." AND FIND_IN_SET('$team_id',tc.teams) AND tc.u_id = u.id AND
tc.reg_emails = 1";
$db->setQuery($query);
$remail1 = $db->loadResultArray();
if ($remail1){
$remail = implode(",",$remail1);
}else{
$remail = "";}
// Send notification email //
$to = $remail;
$subject = "***Reserved***$hs2,$state --$firstname $lastname";
$message = "
<html>
<head><title>Alumni Football USA</title></head>
<body>
<h1>$firstname $lastname</h1>
</body>
</html>
";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= 'From: Alumni Football USA <webmaster@alumnifootballusa.com>' . "\r\n";
// Send notification //
mail($to,$subject, $message, $headers);
///--------------------------------------------------------------///
答案 0 :(得分:0)
问题可能是你变量可能没有电子邮件值:
if ($remail1){
$remail = implode(",",$remail1);
}
else{
$remail = ""; //you might have this
}
$to = $remail; //so if $remail is blank so will be the $to as well
请确保您的$ to变量包含电子邮件,
if(!empty($to)) {
//send email
mail($to,$subject, $message, $headers);
}