我在注册过程中有以下功能,将在完成注册过程后向用户发送电子邮件。我希望电子邮件的文本根据他们是什么类型的用户而有所不同。我有商业用户和个人用户,它们在数据库中被标识为 1 或 0。这就是我到目前为止所拥有的。
function SendBusWelcomeEmail(&$user_rec)
{
$result = mysql_query("SELECT business FROM users")
or die(mysql_error());
while ($row = mysql_fetch_array($result))
{
$actiontype = $row['business'];
switch ($actiontype)
{
case "0":
$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;
}
return true;
break;
case "1":
$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! thanks for your business etc etc 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;
}
return true;
}