导航:首页 > 编程语言 > phpqq邮箱发送邮件

phpqq邮箱发送邮件

发布时间:2022-05-23 19:56:50

① 怎么利用php发送邮件求详细教程

PHP虽然提供了mail()函数,但并不好用,而PHPMailer是一个不错的邮件发送工具,接下来将详细介绍,需要了解的朋友可以参考下:

本人使用wamp集成开发环境,Apache2.4.4, Mysql5.6.12 , php5.4.12.开始的时候使用mail()发送邮件,更改配置始终无法成功,了解到mail()函数使用需要sendmail程序。又下载了sendmail程序扩展包。按照网上的说法也改好了php.ini和sendmail.ini。使用foxmail 7.1创建了自己的qq邮箱账户,开启了POP3/SMTP服务,更改发件服务器为POP3,使用和收件服务器相同的身份验证,结果还是报错:Warning: mail(): SMTP server response: 503 Error: need EHLO and AUTH first ! in F:\PHP\wamp\www\mail.php on line 8。以下是使用mail()函数发送邮件的php代码:

[php] view plain
<span style="font-size:14px"><?php

$to = "[email protected]";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "[email protected]";
$headers = "From: $from";
$send=mail($to,$subject,$message,$headers);
if($send)
echo "Mail Sent";
else
echo "Sorry,mail sent failed!"

?></span>
在CSDN论坛上发现phpmailer可以方便快捷的发送邮件,以下写出详细使用教程:
1.需要下载PHPMailer文件包,(点击打开链接)

2.确认你的服务器已经系统支持socket,通过phpinfo()查看是否支持socket;

3.把文件解压到你的WEB服务器目录下,就可以使用PHPMailer发送邮件了。

以下为前台表单php代码:

[php] view plain
<span style="font-size:14px"><html>
<body>
<h3>phpmailer Unit Test</h3>
请你输入<font color="#FF6666">收信</font>的邮箱地址:
<form name="phpmailer" action="testemail.php" method="post">
<input type="hidden" name="submitted" value="1"/>
邮箱地址: <input type="text" size="50" name="to" />
<br/>
<input type="submit" value="发送"/>
</form>
</body>
</html> </span>
以下为后台程序:

[php] view plain
<?php
/**
* Simple example script using PHPMailer with exceptions enabled
* @package phpmailer
* @version $Id$
*/

header("content-type:text/html;charset=utf-8");

ini_set("magic_quotes_runtime",0);

require('class.phpmailer.php');

try {
$mail = new PHPMailer(true); //New instance, with exceptions enabled

//$body = file_get_contents('contents.html');
//$body = preg_replace('/\\\\/','', $body); //Strip backslashes
$to = $_POST['to'];
$mail->CharSet="GB2312";//设置邮件字符编码否则邮件会乱码
$mail->Encoding="base64";
$mail->IsSMTP(); // tell the class to use SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Port = 25; // set the SMTP server port
$mail->Host = "smtp.qq.com"; // SMTP server
$mail->Username = "[email protected]"; // SMTP server username
$mail->Password = "000000000000"; // SMTP server password

//$mail->IsSendmail(); // tell the class to use Sendmail

$mail->AddReplyTo("[email protected]","han qing");

$mail->From = "[email protected]";
$mail->FromName = "han qing";

//$to = "[email protected]";

$mail->AddAddress($to);

$mail->Subject =$mail->Subject = "=?utf-8?B?" . base64_encode("First PHPMailer Message") . "?=";

$mail->Body = "<h1>phpmailer演示</h1> 这是用PHPMAILER发的第一份邮件,从QQ邮箱发到Google邮箱.";

$mail->AddAttachment("F:/myloe.jpg");

$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->WordWrap = 80; // set word wrap

//$mail->MsgHTML($body);

$mail->IsHTML(true); // send as HTML

$mail->Send();
echo 'Message has been sent.';
} catch (phpmailerException $e) {
echo $e->errorMessage();
}
?>

② 请问一下,PHP配置SMTP怎么弄

PHPMailer的获取:

PHPMailer项目地址:PHPMailer 使用git命令克隆到本地,或直接在该项目页面的右下方点击“ Download ZIP ”即可获取到完整的PHPMailer代码包,再到本地解压即可。

步骤一:使我们的QQ邮箱能够发送邮件

这里怎么说能够发送邮件呢?其实我们的邮箱都是可以发送邮件的,但是要实现在我们的网站中发送邮件,那就要设置一下我们的QQ邮箱了,因为此时我们的网站现在是作为一个第三方客户端存在的。

步骤一:使我们的QQ邮箱能够发送邮件

这里怎么说能够发送邮件呢?其实我们的邮箱都是可以发送邮件的,但是要实现在我们的网站中发送邮件,那就要设置一下我们的QQ邮箱了,因为此时我们的网站现在是作为一个第三方客户端存在的

阅读全文

与phpqq邮箱发送邮件相关的资料

热点内容
无线路由如何设置成服务器 浏览:136
QQ飞车源码更新 浏览:899
虚拟机中编译器 浏览:476
台达PLC编译按钮在哪里 浏览:141
非编程计算器多少钱 浏览:655
房本还完贷款解压 浏览:818
中国程序员有出名吗 浏览:548
亳州云服务器 浏览:632
程序员最难的面试 浏览:894
配音秀app怎么诵读 浏览:751
sparkcore源码 浏览:100
程序员中年生活 浏览:355
读取加密信息失败怎么回事 浏览:510
编译过程之后是预处理吗 浏览:351
安卓是基于什么做出来 浏览:600
视频字幕提取APP怎么使用 浏览:59
js通过ip地址连接服务器吗 浏览:848
java数字金额大写金额 浏览:858
人人影视路由器固件编译 浏览:967
照片通讯录短信怎么从安卓到苹果 浏览:458