我使用 Payson 支付网关,完成支付后,当用户被重定向回感谢页面时,两封相同的电子邮件会发送给用户。请帮我解决这个问题。代码如下:
$select="select * from #__content where id=12 and state=1";
$db->setQuery($select);
$result = $db->loadObject();
echo $result->introtext;
//echo $_REQUEST['id'];
$select = "select * from #__booking order by id desc";
$db->setQuery($select);
$db->query();
$id=$db->loadObject();
$insert_id=$id->id;
$printid=base64_encode($insert_id);
$db=& JFactory::getDBO();
$select_brand="select * from #__booking where id=".$id->id."";
$db->setQuery($select_brand);
$result = $db->loadObject();
$db=& JFactory::getDBO();
$select_brand="select * from #__brand where published=1 and id=".$result->brand."";
$db->setQuery($select_brand);
$result_brand = $db->loadObject();
$select_model="select * from #__modno where published=1 and id=".$result->model."";
$db->setQuery($select_model);
$result_model = $db->loadObject();
$printlink=JURI::root()."print.php?id=".$insert_id;
$link="http://www.status.repair24.se/?id=".$insert_id;
$phoneimagelink=JURI::root()."templates/mobile/images/phicon.png";
$logolink=JURI::root()."templates/mobile/images/2.png";
$to= $result->email;
$subject = "Invoice Mail";
$body.='<center><div style="width:100%;background-color:#f1f3f6;"><br>
<table bgcolor="#dde1e8" cellpadding="10" width="70%" style="border:1px solid #000;">
<tr><td>
<table bgcolor="white" align="center" cellpadding="5" cellspacing="5" width="100%" style="border:1px solid #000;">
<tr>
<td>
<table width="100%">
<tr>
<td align="left"><img src="'.$logolink.'" width="200"></td>
<td align="right"><img src="'.$phoneimagelink.'" style="margin:3px 5px -3px 0" alt="" border="0">123456789</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
Name : '.$result->name.'
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
Address: '.$result->address.'
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
Zip Code: '.$result->zip.'
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
Mobile : '.$result->mobile.'
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
Email : '.$result->email.'
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
Brand : '.$result_brand->name.'
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
Model: '.$result_model->name.'
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
Size '.$result->size.'
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
Imei : '.$result->imei.'
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
Operator : '.$result->operator.'
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
Lock CODE : '.$result->lockcode.'
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
Error Descriptions : '.rtrim($result->repairs,',').'
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
Price : '.$result->price.' SEK
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
Repair Number : '.$result->num.'
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
<a href='.$printlink.'>Click here </a>to print Your Booking Details.
</td>
</tr>
<tr>
<td style="font-size:12px;font-family:Arial;" align="left">
<a href='.$link.'>Click here </a>to check status.
</td>
</tr>
</table></td></tr></table><br><br></div></center>';
// To send HTML mail, the Content-type header must be set
$from = array("info@repair24.se", "Repair 24");
// To send HTML mail, the Content-type header must be set
# Invoke JMail Class
$mailer = JFactory::getMailer();
# Set sender array so that my name will show up neatly in your inbox
$mailer->setSender($from);
# Add a recipient -- this can be a single address (string) or an array of addresses
$mailer->addRecipient($to);
$mailer->setSubject($subject);
$mailer->setBody($body);
# If you would like to send as HTML, include this line; otherwise, leave it out
$mailer->isHTML(1);
# Send once you have set all of your options
$ma=$mailer->send();