在确认注册后,我正在尝试向用户发送不同的电子邮件。一个用于管理员用户,另一个文本用于基本用户。我根据查询的数据编写了 if else 语句,但它向这两种类型的用户发送了两封电子邮件。知道有什么问题吗?
function SendBusWelcomeEmail(&$user_rec)
{
$result = mysql_query("SELECT business FROM users")
or die(mysql_error());
if($result='a') {
$mailer = new PHPMailer();
$mailer->CharSet = 'utf-8';
$mailer->AddAddress($user_rec['email'],$user_rec['name']);
$mailer->Subject = "Welcome to ".$this->sitename;
$mailer->From = $this->GetFromAddress();
$mailer->Body ="Thank You ".$user_rec['name']." for joining xxx, \r\n\r\n".
"We are a brand new business with big ambitions. Our mission is to help the development of your skills \r\n".
"\r\n".
"Regards,\r\n".
"Webmaster\r\n".
$this->sitename;
}
if(!$mailer->Send())
{
$this->HandleError("Failed sending user welcome email.");
return false;
}
else{
$mailer = new PHPMailer();
$mailer->CharSet = 'utf-8';
$mailer->AddAddress($user_rec['email'],$user_rec['name']);
$mailer->Subject = "Welcome to ".$this->sitename;
$mailer->From = $this->GetFromAddress();
$mailer->Body ="Hello ".$user_rec['name']."\r\n\r\n".
"Welcome! Your registration with ".$this->sitename." is completed.\r\n".
"\r\n".
"Regards,\r\n".
"Webmaster\r\n".
$this->sitename;
if(!$mailer->Send())
{
$this->HandleError("Failed sending user welcome email.");
return false;
}
}
}