导航:首页 > 编程语言 > phpphpmailer下载

phpphpmailer下载

发布时间:2022-04-24 00:30:28

phpmailer怎么使用

您好,看下第一个例子的代码
require("class.phpmailer.php");//这个就是包含你下载的phpmailer类的网页,必须

$mail = new phpmailer();//创建对象

$mail->From = "[email protected]";//给对象的属性赋值,就是发件人的邮箱地址
$mail->FromName = "List manager";//发件人的名称
$mail->Host = "smtp1.example.com;smtp2.example.com";//邮件主机的smtp地址
$mail->Mailer = "smtp";
//下面是邮件内容要用到的代码
@MYSQL_CONNECT("localhost","root","password");
@mysql_select_db("my_company");
$query = "SELECT full_name, email,爌hoto焖ROM employee燱HERE爄d=$id";
$result =燖MYSQL_QUERY($query);

while ($row = mysql_fetch_array ($result))
{
// HTML body
$body = "Hello <font size=\"4\">" . $row["full_name"] . "</font>, <p>";
$body .= "<i>Your</i> personal photograph to this message.<p>";
$body .= "Sincerely, <br>";
$body .= "phpmailer List manager";

// Plain text body (for mail clients that cannot read HTML)
$text_body = "Hello " . $row["full_name"] . ", \n\n";
$text_body .= "Your personal photograph to this message.\n\n";
$text_body .= "Sincerely, \n";
$text_body .= "phpmailer List manager";
//上面就是你邮件要发送的内容,修改成自己的就可以了
$mail->Body = $body;
$mail->AltBody = $text_body;
$mail->AddAddress($row["email"], $row["full_name"]);//注意这个就是收件人,

$mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");

if(!$mail->Send())//开始发送
echo "There has been a mail error sending to " . $row["email"] . "<br>";

// Clear all addresses and attachments for next loop
$mail->ClearAddresses();
$mail->ClearAttachments();
}

以上用到的属性方法可以查看class.phpmailer.php的代码,很容易知道是干什么的。下的包里也应该有简单的例子,可以看下。

用法看下面的例子,不就是一个类嘛。

Examples using phpmailer
1. Advanced Example

This demonstrates sending out multiple email messages with binary attachments from a MySQL database with multipart/alternative support.

require("class.phpmailer.php");

$mail = new phpmailer();

$mail->From = "[email protected]";
$mail->FromName = "List manager";
$mail->Host = "smtp1.example.com;smtp2.example.com";
$mail->Mailer = "smtp";

@MYSQL_CONNECT("localhost","root","password");
@mysql_select_db("my_company");
$query = "SELECT full_name, email,爌hoto焖ROM employee燱HERE爄d=$id";
$result =燖MYSQL_QUERY($query);

while ($row = mysql_fetch_array ($result))
{
// HTML body
$body = "Hello <font size=\"4\">" . $row["full_name"] . "</font>, <p>";
$body .= "<i>Your</i> personal photograph to this message.<p>";
$body .= "Sincerely, <br>";
$body .= "phpmailer List manager";

// Plain text body (for mail clients that cannot read HTML)
$text_body = "Hello " . $row["full_name"] . ", \n\n";
$text_body .= "Your personal photograph to this message.\n\n";
$text_body .= "Sincerely, \n";
$text_body .= "phpmailer List manager";

$mail->Body = $body;
$mail->AltBody = $text_body;
$mail->AddAddress($row["email"], $row["full_name"]);
$mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");

if(!$mail->Send())
echo "There has been a mail error sending to " . $row["email"] . "<br>";

// Clear all addresses and attachments for next loop
$mail->ClearAddresses();
$mail->ClearAttachments();
}

2. Extending phpmailer

Extending classes with inheritance is one of the most powerful features of object-oriented programming. It allows you to make changes to the original class for your own personal use without hacking the original classes. Plus, it is very easy to do. I've provided an example:

Here's a class that extends the phpmailer class and sets the defaults for the particular site:
PHP include file: mail.inc.php

require("class.phpmailer.php");

class my_phpmailer extends phpmailer {
// Set default variables for all new objects
var $From = "[email protected]";
var $FromName = "Mailer";
var $Host = "smtp1.example.com;smtp2.example.com";
var $Mailer = "smtp"; // Alternative to IsSMTP()
var $WordWrap = 75;

// Replace the default error_handler
function error_handler($msg) {
print("My Site Error");
print("Description:");
printf("%s", $msg);
exit;
}

// Create an additional function
function do_something($something) {
// Place your new code here
}
}

Now here's a normal PHP page in the site, which will have all the defaults set above:
Normal PHP file: mail_test.php

require("mail.inc.php");

// Instantiate your new class
$mail = new my_phpmailer;

// Now you only need to add the necessary stuff
$mail->AddAddress("[email protected]", "Josh Adams");
$mail->Subject = "Here is the subject";
$mail->Body = "This is the message body";
$mail->AddAttachment("c:/temp/11-10-00.zip", "new_name.zip"); // optional name

if(!$mail->Send())
{
echo "There was an error sending the message";
exit;
}

echo "Message was sent successfully";

上面2个就是简单的例子啊!你照着改改就是了。

② PHP邮件发送

可以的,PHP直接连接SMTP服务器,进行登录和发送邮件。不过不可能简单哦,相当于编写一个OUTLOOK的功能,不可能很简单,可以参见这篇文章:http://www.chinaz.com/Program/PHP/041050242007.html

③ 我的phpmailer组件在本地能一切正常,但是上传到空间后,显示发送成功。却收不到邮件。求救

看了每次,我的代码给你参考下,我能发送成功的,希望有帮助,账号密码涂成了xxx,相信你懂得
header("Content-Type: text/html;charset=utf-8");
include 'PHPMailer/class.phpmailer.php';

$mail=new PHPMailer();
$mail->IsSMTP();
$mail->Host='smtp.163.com';
$mail->SMTPAuth=true;
$mail->Username='xxxxxx';
$mail->Password='xxxxxx';
$mail->CharSet='utf-8';
$mail->SMTPDebug=true;

$mail->From='[email protected]';
$mail->FromName='dk';
$mail->Subject='这是第一封信--xxx---程序发送';

$mail->IsHTML('true');
$mail->Body="<h1>哈哈,您好</h1>";

$mail->AddAddress('[email protected]');

if($mail->Send()){
echo "发送成功";
}

④ phpmailer在哪里下载

http://www.oschina.net/p/phpmailer

点软件下载

或者

http://sourceforge.net/projects/phpmailer/files/phpmailer%20for%20php5_6/PHPMailer%20v5.1/

http://sourceforge.net/projects/phpmailer/

⑤ phpmailer怎么使用

我这里有一个写好了的代码,我也是一直在用的例子:网络网盘的,你自己下。 解压后将文件夹mail里面有个mail.php,你打开这个文件,里面有需要配置的参数,你配置好了,就用浏览器访问这个文件,然后进邮箱看看就知道有没有邮件了。

⑥ phpmailer到底怎么用

你看下第一个例子的代码
require("class.phpmailer.php");//这个就是包含你下载的phpmailer类的网页,必须

$mail = new phpmailer();//创建对象

$mail->From = "[email protected]";//给对象的属性赋值,就是发件人的邮箱地址
$mail->FromName = "List manager";//发件人的名称
$mail->Host = "smtp1.example.com;smtp2.example.com";//邮件主机的smtp地址
$mail->Mailer = "smtp";
//下面是邮件内容要用到的代码
@MYSQL_CONNECT("localhost","root","password");
@mysql_select_db("my_company");
$query = "SELECT full_name, email,爌hoto焖ROM employee燱HERE爄d=$id";
$result =燖MYSQL_QUERY($query);

while ($row = mysql_fetch_array ($result))
{
// HTML body
$body = "Hello <font size=\"4\">" . $row["full_name"] . "</font>, <p>";
$body .= "<i>Your</i> personal photograph to this message.<p>";
$body .= "Sincerely, <br>";
$body .= "phpmailer List manager";

// Plain text body (for mail clients that cannot read HTML)
$text_body = "Hello " . $row["full_name"] . ", \n\n";
$text_body .= "Your personal photograph to this message.\n\n";
$text_body .= "Sincerely, \n";
$text_body .= "phpmailer List manager";
//上面就是你邮件要发送的内容,修改成自己的就可以了
$mail->Body = $body;
$mail->AltBody = $text_body;
$mail->AddAddress($row["email"], $row["full_name"]);//注意这个就是收件人,

$mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");

if(!$mail->Send())//开始发送
echo "There has been a mail error sending to " . $row["email"] . "<br>";

// Clear all addresses and attachments for next loop
$mail->ClearAddresses();
$mail->ClearAttachments();
}

以上用到的属性方法可以查看class.phpmailer.php的代码,很容易知道是干什么的。下的包里也应该有简单的例子,可以看下。

用法看下面的例子,不就是一个类嘛。

Examples using phpmailer
1. Advanced Example

This demonstrates sending out multiple email messages with binary attachments from a MySQL database with multipart/alternative support.

require("class.phpmailer.php");

$mail = new phpmailer();

$mail->From = "[email protected]";
$mail->FromName = "List manager";
$mail->Host = "smtp1.example.com;smtp2.example.com";
$mail->Mailer = "smtp";

@MYSQL_CONNECT("localhost","root","password");
@mysql_select_db("my_company");
$query = "SELECT full_name, email,爌hoto焖ROM employee燱HERE爄d=$id";
$result =燖MYSQL_QUERY($query);

while ($row = mysql_fetch_array ($result))
{
// HTML body
$body = "Hello <font size=\"4\">" . $row["full_name"] . "</font>, <p>";
$body .= "<i>Your</i> personal photograph to this message.<p>";
$body .= "Sincerely, <br>";
$body .= "phpmailer List manager";

// Plain text body (for mail clients that cannot read HTML)
$text_body = "Hello " . $row["full_name"] . ", \n\n";
$text_body .= "Your personal photograph to this message.\n\n";
$text_body .= "Sincerely, \n";
$text_body .= "phpmailer List manager";

$mail->Body = $body;
$mail->AltBody = $text_body;
$mail->AddAddress($row["email"], $row["full_name"]);
$mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");

if(!$mail->Send())
echo "There has been a mail error sending to " . $row["email"] . "<br>";

// Clear all addresses and attachments for next loop
$mail->ClearAddresses();
$mail->ClearAttachments();
}

2. Extending phpmailer

Extending classes with inheritance is one of the most powerful features of object-oriented programming. It allows you to make changes to the original class for your own personal use without hacking the original classes. Plus, it is very easy to do. I've provided an example:

Here's a class that extends the phpmailer class and sets the defaults for the particular site:
PHP include file: mail.inc.php

require("class.phpmailer.php");

class my_phpmailer extends phpmailer {
// Set default variables for all new objects
var $From = "[email protected]";
var $FromName = "Mailer";
var $Host = "smtp1.example.com;smtp2.example.com";
var $Mailer = "smtp"; // Alternative to IsSMTP()
var $WordWrap = 75;

// Replace the default error_handler
function error_handler($msg) {
print("My Site Error");
print("Description:");
printf("%s", $msg);
exit;
}

// Create an additional function
function do_something($something) {
// Place your new code here
}
}

Now here's a normal PHP page in the site, which will have all the defaults set above:
Normal PHP file: mail_test.php

require("mail.inc.php");

// Instantiate your new class
$mail = new my_phpmailer;

// Now you only need to add the necessary stuff
$mail->AddAddress("[email protected]", "Josh Adams");
$mail->Subject = "Here is the subject";
$mail->Body = "This is the message body";
$mail->AddAttachment("c:/temp/11-10-00.zip", "new_name.zip"); // optional name

if(!$mail->Send())
{
echo "There was an error sending the message";
exit;
}

echo "Message was sent successfully";

上面2个就是简单的例子啊!你照着改改就是了

⑦ 怎么利用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 mail函数到底怎么配置

你要用mail就得用smtp服务软件,然后配送smtp的用户名和密码,端口号,然后在php mail的配置文件里配置一下SMTP的地址,用户名密码端口号等。

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

PHPMailer的获取:

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

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

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

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

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

阅读全文

与phpphpmailer下载相关的资料

热点内容
云服务器关机网址不见了 浏览:69
余冠英pdf 浏览:755
开发一个app上市需要什么步骤 浏览:28
phpsleep方法 浏览:430
时间同步服务器ip地址6 浏览:926
钢琴谱pdf下载 浏览:524
香港阿里云服务器怎么封udp 浏览:875
APp买海鲜到哪里 浏览:501
辽油社保app总提示更新怎么办 浏览:586
导入源码教程视频 浏览:613
天翼贷app在哪里下载 浏览:186
app开发源码查看器 浏览:516
程序员发展到了一个瓶颈 浏览:120
程序员去机房干嘛 浏览:697
英雄训练师怎么看曾经服务器 浏览:546
魔兽世界单机输入gm命令 浏览:372
51单片机最大负跳距是多少 浏览:418
android聊天控件 浏览:128
导致压缩机坏的原因 浏览:295
如何多次选取文件夹 浏览:280