Curl sends MAIL-help for help. CURL fails to send MAIL. please refer to the code for more information.
"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 ', 'subobject' => inlineCode ($ smtp ['subobject']), '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; // verify login $ content. = "mail from :". $ smtp ["from"]. $ CRLF; // sending address $ content. = "rcpt :". $ smtp ["to"]. $ CRLF; // recipient address $ content. = "DATA ". $ CRLF. $ data. $ CRLF. ". ". $ CRLF; // sends content $ content. = "QUIT ". $ CRLF; // exit curl_setopt ($ curl, CURLOPT_RETURNTRANSFER, true); // curl_setopt ($ curl, CURLOPT_CUSTOMREQUEST, $ content) returned by curl ); $ test = curl_exec ($ curl); var_dump ($ test); echo"
\ R \ n "; var_dump ($ content); // end curl_close ($ curl );
Reply to discussion (solution)
Who can give me some advice?
I really don't know whether curl has this function. I directly use sendmail
Also, you need to write the login process before using socket communication.