$jmail = new COM('JMail.Message') or die('无法调用Jmail组件');
$jmail->silent = true; //屏蔽例外错误
$jmail->charset = 'gb2312'; //否则中文会乱码
$jmail->From = '[email protected]'; //这里理论上是可以不与发件人地址相同的,但用163的试了几次都不行,改
成一样的就可以了
$jmail->FromName = 'BoboTest';
$jmail->AddRecipient('[email protected]'); //可添加多个邮件接受者
//$jmail->AddRecipient('[email protected]');
//$jmail->AddRecipient('[email protected]');
$jmail->Subject = 'email test.';
$jmail->Body = 'this is test email.';
$jmail->MailServerUserName = '[email protected]'; //发信邮件账号
$jmail->MailServerPassword = '123456'; //账户的密码
try{
$email = $jmail->Send('smtp.163.com');
if($email) echo '发送成功';
else echo '发送失败';
} catch (Exception $e){
echo $e->getMessage();
}
?>
|