email via phpmailer

class.phpmailer.php
class.smtp.php

mail.php

<?php

require("./class.phpmailer.php");

function SmtpMail($send_to_mail,$subject,$body,$extra_hdrs,$username){

$mail=new PHPMailer();
$mail->IsSMTP();
$mail->Host="mail.xxx.net";
$mail->SMTPAuth=false;
$mail->Username="";
$mail->Password="";
$mail->From="";
$mail->FromName="xxx Mailer";
$mail->CharSet="utf-8";
$mail->AddAddress($send_to_mail,"$username");
$mail->AddReplyTo("xxx Mailer","no-reply");
$mail->IsHTML(true);
$mail->Subject=$subject;

if ($body==''){
$mail->Body="";
} else {
$mail->Body="<html><head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'></head>
<body>".$body."
</body>
</html>";
}

$mail->AltBody="text/html";
if (@ !$mail->Send()) {
$results=array("result"=>false,"message"=>$mail->ErrorInfo);
return $results;
}else{
$results = array("result"=>true,"message"=>"{$send_to_mail} was sent out.");
return $results;
}
}

$reservation['date'] = $_POST['date'];

$reservation['time'] = $_POST['time'];

$reservation['number'] = $_POST['number'];

$reservation['name'] = $_POST['name'];
$reservation['phone'] = $_POST['phone'];
$reservation['email'] = $_POST['email'];
$reservation['made'] = $_POST['made'];
$reservation['not_made'] = $_POST['not_made'];
$reservation['info'] = $_POST['info'];

$th['date'] = 'Date';
$th['time'] = 'Time';
$th['number'] = 'Number of People';
$th['name'] = 'Name';
$th['phone'] = 'Phone Number';
$th['email'] = 'Email Address';
$th['made'] = 'Preferred contact method<br />if Reservation made';
$th['not_made'] = 'Preferred contact method if Reservation<br />NOT available at requested Date / Time';
$th['info'] = 'Further Infomation';

$table_tr = '';
foreach($reservation as $k=>$v) {
$table_tr .= '<tr>';
$table_tr .= '<th align="left">'.$th[$k].'</th><td>'.htmlspecialchars(strip_tags($v)).'</td>';
$table_tr .= '</tr>';
}
$subject = "New Reservation";
$body = "<h2>$subject</h2><table border=1>$table_tr</table>";

$send_mail=SmtpMail('xxx@xxx.com',$subject,$body,'','');


if($send_mail["result"]){
$direct = 'thank-you';
}else{
$direct = 'sorry';
}

echo '<script type="text/javascript">location="processing.php?r='.$direct.'";</script>';


processing.php

<?php
$title['thank-you'] = 'Thank you';
$title['sorry'] = 'Sorry';
$content['thank-you'] = 'Thank you for submitting a Reservation request. xxx will personally contact you ASAP to confirm your Reservation.</p>
<p>We look forward to seeing you at xxx.';
$content['sorry'] = 'Sorry, there is something wrong with the processing, please try it later or phone us on xxx.';
?>
<h1><?php echo $title[$_GET['r']];?></h1><br /><br />

<p><?php echo $content[$_GET['r']];?></p>




e.g. 163 mail

$mail=new PHPMailer();
$mail->IsSMTP();
$mail->Host="smtp.163.com";
$mail->SMTPAuth=true;
$mail->Username="xxx";
$mail->Password="xxx";
$mail->From="xxx@163.com";
$mail->FromName="xxx Mailer";
$mail->CharSet="utf-8";
$mail->AddAddress($send_to_mail,"$username");
$mail->AddReplyTo("xxx@163.com","no-reply");
$mail->IsHTML(true);
$mail->Subject=$subject;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值