Home > php教程 > php手册 > BAE环境发送邮件

BAE环境发送邮件

WBOY
Release: 2016-06-06 20:10:15
Original
1216 people have browsed it

BAE环境禁用了mail函数,发送邮件可以通过smtp方式发送 参考如下内容: 1 BAE中用socket系列函数通过smtp协议发送邮件 2 PHP SOCKET()方式发送邮件 3 PHPMailer 其中,1可以发送邮件,但太简单了,最基本的邮件通信内容,没有收件人和标题、内容 2和3总也折

BAE环境禁用了mail函数,发送邮件可以通过smtp方式发送

参考如下内容:
1 BAE中用socket系列函数通过smtp协议发送邮件
2 PHP SOCKET()方式发送邮件
3 PHPMailer

其中,1可以发送邮件,但太简单了,最基本的邮件通信内容,没有收件人和标题、内容
2和3总也折腾不出,作罢

改良一下1的代码,可以增加相应的内容:


<br><?php <br />$server = "smtp.163.com";<br>$port = 25;//默认25<br>$username = "YOURNAME@163.com" ;<br>$password = "YOURPASSWORD";//密码<br>$sendto = "TOWHO@gmail.com";//邮件接收者地址<br>$subject = "test title2";<br>$content = "test content2";<br><br>$header = "MIME-Version:1.0\r\n";  <br>$header .= "To: ".$sendto."\r\n";  <br>$header .= "From: $username\r\n";  <br>$header .= "Subject: ".$subject."\r\n";  <br><br>$data = $header."\r\n".$content;//邮件内容<br><br>$sock = socket_create(AF_INET,SOCK_STREAM,SOL_TCP);<br>if(socket_connect($sock,$server,$port)===false)socket_strerror(socket_last_error());<br>echo socket_read($sock,100)."";<br>socket_write($sock,"HELO lyz810\r\n");<br>echo socket_read($sock,100)."";<br>socket_write($sock,"AUTH LOGIN\r\n");<br>echo socket_read($sock,100)."";<br>socket_write($sock,base64_encode($username)."\r\n");<br>echo socket_read($sock,100)."";<br>socket_write($sock,base64_encode($password)."\r\n");<br>echo socket_read($sock,100)."";<br>socket_write($sock,"MAIL FROM:\r\n");<br>echo socket_read($sock,100)."";<br>socket_write($sock,"RCPT TO:\r\n");<br>echo socket_read($sock,100)."";<br>socket_write($sock,"DATA\r\n");<br>echo socket_read($sock,100)."";<br>socket_write($sock,$data."\r\n.\r\n");<br>socket_write($sock,"QUIT");<br>echo socket_read($sock,100)."";<br>
    <p class="copyright">
        原文地址:BAE环境发送邮件, 感谢原作者分享。
    </p>
    
    


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