使用phpmailer发送邮件

在PHP脚本中发送邮件除了使用自带的mail()函数,还可以使用流行的phpmailer插件,不近配置方便而且功能强大。

  1. 下载phpmailer所需文件phpmailer文件下载
  2. 发送邮件:
        require('class.phpmailer.php');
	require('class.smtp.php');
	$mail = new PHPMailer();//初始化
	$mail->IsSMTP();
	$mail->SMTPAuth = true;
	$mail->CharSet = 'utf-8';
	$mail->Port = 465;
	$mail->SMTPSecure = 'ssl';//'tls'根据设置的邮箱进行配置;
	$mail->Host = 'smtp.mxhichina.com';
	$mail->IsHTML(FALSE);
	
        $mail->FromName = "DF";
	$mail->Username = 'xxxxx@xxx.com';//用户名,一般与邮箱一致
	$mail->From = 'xxxxx@xxx.com';//邮箱
	$mail->Password = '12345';//密码
	$mail->Subject = 'Prediction result';//邮件主题
	$mail->AddAddress($email);//发送邮箱地址
	$mail->AddAttachment('drugFitness.txt','PredictionResult.txt');//添加附件,并且重命名
	$mail->Body='Here is your prediction result , please see the attachment'.PHP_EOL.'Thank you for your support';//邮件主体
	$mail->Send();//发送
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值