Home > php教程 > php手册 > PHP发送邮件,php发送邮件代码

PHP发送邮件,php发送邮件代码

WBOY
Release: 2016-06-13 08:57:05
Original
1167 people have browsed it

PHP发送邮件,php发送邮件代码

PHP发送邮件代码

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?<span>php
</span><span>//</span><span>使用网吧数据接口,发送邮件php demo
//本程序,你只需要改配置值,然后直接运行即可

//=======
//配置程序
//=======</span>

<span>#</span><span>网吧数据KEY</span>
<span>$key</span>    =    '14297580222735684725947490211595'<span>;
</span><span>#</span><span> smtp服务器地址, 如smtp.qq.com</span>
<span>$host</span> = 'smtp.qq.com'<span>;
</span><span>#</span><span> 发件人名称</span>
<span>$fromname</span> = '昵称随便定义'<span>;
</span><span>#</span><span> 发件人邮箱账号</span>
<span>$username</span> = 'QQ邮箱账号'<span>;
</span><span>#</span><span> 发件人邮箱密码</span>
<span>$passwd</span> = 'QQ邮箱密码'<span>;
</span><span>#</span><span> 收件人邮箱账号</span>
<span>$to</span> = '3039439790@qq.com'<span>;
</span><span>#</span><span> 邮件标题</span>
<span>$subject</span> = '标题,您好!'<span>;
</span><span>#</span><span> 邮件内容,可以写HTML,等</span>
<span>$email</span> = '内容,您好,这是我们为您准备的内容。'<span>;

</span><span>//</span><span>=======
//逻辑处理程序
//=======</span>

<span>$subject</span>    =    <span>urlencode</span>(<span>$subject</span><span>);
</span><span>$email</span>    =    <span>urlencode</span>(<span>$email</span><span>);
</span><span>$handle</span> = <span>fopen</span> ("http://www.zgw8.com/api.php/SendMail/Index/key/".<span>$key</span>."/language/xml/smtp/".<span>$host</span>."/fajianrenmingcheng/".<span>$fromname</span>."/fajianrenyouxiang/".<span>$username</span>."/fajianrenyouxiangmima/".<span>$passwd</span>."/shoujianrenyouxiang/".<span>$to</span>."/youjianbiaoti/".<span>$subject</span>."/youjianneirong/".<span>$email</span>, "rb"<span>);
</span><span>$contents</span> = ""<span>;
</span><span>while</span> (!<span>feof</span>(<span>$handle</span><span>)) {
    </span><span>$contents</span> .= <span>fread</span>(<span>$handle</span>, 8192<span>);
}
</span><span>fclose</span>(<span>$handle</span><span>);
</span><span>function</span> simplest_xml_to_array(<span>$xmlstring</span><span>) {
    </span><span>return</span> json_decode(json_encode((<span>array</span>) <span>simplexml_load_string</span>(<span>$xmlstring</span>)), <span>true</span><span>);
}




</span><span>//</span><span>=======
//获取到结果的程序
//=======

//返回值数组</span>
<span>$arr</span>    =    simplest_xml_to_array(<span>$contents</span><span>);
</span><span>//</span><span>打印数组</span>
<span>print_r</span>(<span>$arr</span><span>);

</span>?>
Copy after login

 

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