Home > php教程 > php手册 > PHP发邮件函数实现代码

PHP发邮件函数实现代码

WBOY
Release: 2016-05-25 16:49:31
Original
1294 people have browsed it

不需要邮件服务器,不使用mail内置函数,一个类就搞定,利用phpmailer类我写了一个自定义函数 sendmail(),very实用!

以前也在几个php论坛上发表过这个发邮件的函数,今天再发,因为today要附上使用例子,如果你还不会用,那就要补补php基础课了。

1.准备文件 sendmail.class.php文件、phpmailer类下载  

2.下载后,解压 phpmailer.rar 到服务器的任何目录下

3.打开 sendmail.class.php,修改如下(浅黄色部分是必须 要修改的变量值)

// 以下 5 个变量值必须据实修改 
$host     = '61.183.41.172'; 
$username = 'admin@php95.com'; 
$password = "******"       
$from     = 'admin@php95.com';     
$fromname = '天马博客';   
// 先设置 $to $subject $content 这三个变量的值,再调用 sendmail 函数来发送邮件 
$to = 'nt2030@qq.com'; 
$subject = '测试phpmailer类发送邮件'; 
$content = '测试phpmailer类发送邮件'; 
sendmail($to,$subject,$content);
Copy after login

4.修改 sendmail.class.php 完毕后,运行它..

你的邮件是否发送成功?天马测试本代码,is ok,见证:


本文地址:

转载随意,但请附上文章地址:-)

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template