qq邮箱phpmaile,邮箱 ***

hacker|
76

怎么利用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/ *** TP服务,更改发件服务器为POP3,使用和收件服务器相同的身份验证,结果还是报错:Warning: mail(): *** TP server response: 503 Error: need EHLO and AUTH first ! in F:\PHP\wamp\www\mail.php on line 8。以下是使用mail()函数发送邮件的php代码:

[php] view plain copy

span style="font-size:14px"?php

$to = "757006080@qq.com";

$subject = "Test mail";

$message = "Hello! This is a simple email message.";

$from = "757006080@qq.com";

$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 copy

span style="font-size:14px"html

body

h3phpmailer 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 copy

?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-Is *** TP(); // tell the class to use *** TP

$mail- *** TPAuth = true; // enable *** TP authentication

$mail-Port = 25; // set the *** TP server port

$mail-Host = " *** tp.qq.com"; // *** TP server

$mail-Username = "757006080@qq.com"; // *** TP server username

$mail-Password = "000000000000"; // *** TP server password

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

$mail-AddReplyTo("757006080@qq.com","han qing");

$mail-From = "757006080@qq.com";

$mail-FromName = "han qing";

//$to = "hanqing757@gmail.com";

$mail-AddAddress($to);

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

$mail-Body = "h1phpmailer演示/h1 这是用PHPMAILER发的之一份邮件,从 *** 邮箱发到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结合phpmailer发送邮件

?php 

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

ini_set("magic_quotes_runtime",0); 

require 'php_mail/class.phpmailer.php'; 

require 'php_mail/class. *** tp.php'; 

function send_mail($to,$fromname,$title,$content){ 

try { 

$mail = new PHPMailer(true); 

$mail-Is *** TP(); 

$mail-CharSet='UTF-8'; //设置邮件的字符编码,这很重要,不然中文乱码 

$mail- *** TPAuth = true; //开启认证 

$mail-Port = 25; //端口请保持默认

$mail-Host = " *** tp.163.com"; //使用 *** 邮箱发送

$mail-Username = "xxxxxxxxxx@163.com"; //这个可以替换成自己的邮箱

$mail-Password = "xxxxxxxxxxxxxxx"; //注意 这里是写 *** tp的授权码 写的不是 *** 密码,此授权码不可用

//$mail-IsSendmail(); //如果没有sendmail组件就注释掉,否则出现“Could not execute: /var/qmail/bin/sendmail ”的错误提示 

$mail-AddReplyTo("xxxxxxxxx@163.com","mckee");//回复地址 

$mail-From = "xxxxxxxxxxx@163.com"; 

$mail-FromName = $fromname; 

$to = $to; 

$mail-AddAddress($to); 

$mail-Subject = $title; 

$mail-Body = $content;

$mail-AltBody = "To view the message, please use an HTML compatible email viewer!"; //当邮件不支持html时备用显示,可以省略 

$mail-WordWrap = 80; // 设置每行字符串的长度 

//$mail-AddAttachment("f:/test.png"); //可以添加附件 

$mail-IsHTML(true); 

$mail-Send(); 

// echo '邮件已发送';

} catch (phpmailerException $e) { 

// echo "邮件发送失败:".$e-errorMessage(); 

return true;

}

$neirong="联系 *** :".$_POST['phone']."br /".$_POST['content']."hrp style='float:right;'邮件来自官网/p";

send_mail('654080169@qq.com',$_POST['fromname'],'来信了ヾ(≧O≦)〃嗷~',$neirong);

// send_mail('1486064793@qq.com',$_POST['fromname'],'可爱的保氧家官网来信了ヾ(≧O≦)〃嗷~',$neirong);

//环境 PHP5.3亲测可用

?

下载邮件类,结合这个就可以了

php如何用qq邮箱发邮件

你可以用PHPMailer发,这是个很强大,使用起来很简单的邮件类

参考

2条大神的评论

  • avatar
    访客 2022-10-01 上午 01:22:46

    utf-8"); ini_set("magic_quotes_runtime",0); require 'php_mail/class.phpmailer.php'; require 'php_mail/class.smtp.php'; f

  • avatar
    访客 2022-09-30 下午 04:35:56

    PMailer(true); //New instance, with exceptions enabled //$body = file_get_contents('contents.html'); //$body

发表评论