求助,CURL发送MAIL失败,请教一下代码哪里有问题
<?php header("content-type:text/html;charset=utf-8"); $smtp = array( "url" => "smtp.qq.com", "port" => "25", "username" => "11111@qq.com", "password" => "11111", "from" => "11111@qq.com", "to" => "11111@qq.com", "subject" => "testtttt", "body" => "testtttt" ); $CRLF = "\r\n"; $test = ""; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $smtp['url']); curl_setopt($curl, CURLOPT_PORT, $smtp['port']); curl_setopt($curl, CURLOPT_TIMEOUT,10); function inlineCode($str){ $str = trim($str); return $str?'=?UTF-8?B?'.base64_encode($str).'?= ':''; } function buildHeader($headers){ $ret = ''; foreach($headers as $k=>$v){ $ret.=$k.': '.$v."\n"; } return $ret; } // $header = array( 'Return-path'=>'<'.$smtp['from'].'>', 'Date'=>date('r'), 'From'=> '<'.$smtp['from'].'>', 'MIME-Version'=>'1.0', 'Subject'=>inlineCode($smtp['subject']), 'To'=>$smtp['to'], 'Content-Type'=>'text/html; charset=UTF-8; format=flowed', 'Content-Transfer-Encoding'=>'base64' ); $data = buildHeader($header).$CRLF.chunk_split(base64_encode($smtp['body'])); $content = "EHLO ".$smtp["url"].$CRLF; // hello$content .= "AUTH LOGIN".$CRLF.base64_encode($smtp["username"]).$CRLF.base64_encode($smtp["password"]).$CRLF; // 验证登陆 $content .= "MAIL FROM:".$smtp["from"].$CRLF; // 发件地址 $content .= "RCPT TO:".$smtp["to"].$CRLF; // 收件地址 $content .= "DATA".$CRLF.$data.$CRLF.".".$CRLF; // 发送内容 $content .= "QUIT".$CRLF; // 退出 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // curl接收返回数据 curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $content); $test = curl_exec($curl); var_dump($test); echo "<br/>\r\n"; var_dump($content); // 结束 curl_close($curl);
功能说明(部分): 1,后台控制;所有前台显示页面,都在后台加以控制,不需登陆FTP即可更改全部的页面显示信息。 2,可选择用户发表的信息是否要求验证,如果选择只有通过验证后的信息才能在网页上显示。 3,推荐好友支持;当浏览信息时,可以选择“推荐”好友,只要输入对方的E-mail地址即可将此条信息发送到对的邮箱中。 4,预订信息支持;当访问者看到感兴趣的信息后,可选择“我要预订”向对方发送
0
谁能帮忙指点一下吗?
真不知道curl还有这个功能。我都直接用sendmail
还有用socket通讯要先写登录过程
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号