Mam problem ze skryptem wysylajacym maile za pomoca smtp. skrypt pochodzi ze strony http://www.tutorialized.com/tutorial/Sendi...sing-SMTP/12680
<?php //new function $to = "post@example.com"; $nameto = "Who To"; $from = "post@example.com"; $namefrom = "Who From"; $subject = "Hello World Again!"; $message = "World, Hello!" authSendEmail($from, $namefrom, $to, $name to, $subject, $message); ?> //Authenticate Send - 21st March 2005 //This will send an email using auth smtp and output a log array //logArray - connection, function authSendEmail($from, $namefrom, $to, $nameto, $subject, $message) { $smtpServer = "mail.server.com"; $port = "25"; $timeout = "30"; $username = "smtpusername"; $password = "smtppassword"; $localhost = "localhost"; $newLine = "rn"; /* * * * CONFIGURATION END * * * * */ //Connect to the host on the specified port $smtpConnect = fsockopen($smtpServer, $port, $errno, $errstr, $timeout); $smtpResponse = fgets($smtpConnect, 515); if(empty($smtpConnect)) { $output = "Failed to connect: $smtpResponse"; return $output; } else { $logArray['connection'] = "Connected: $smtpResponse"; } //Request Auth Login fputs($smtpConnect,"AUTH LOGIN" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['authrequest'] = "$smtpResponse"; //Send username fputs($smtpConnect, base64_encode($username) . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['authusername'] = "$smtpResponse"; //Send password fputs($smtpConnect, base64_encode($password) . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['authpassword'] = "$smtpResponse"; //Say Hello to SMTP fputs($smtpConnect, "HELO $localhost" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['heloresponse'] = "$smtpResponse"; //Email From fputs($smtpConnect, "MAIL FROM: $from" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['mailfromresponse'] = "$smtpResponse"; //Email To fputs($smtpConnect, "RCPT TO: $to" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['mailtoresponse'] = "$smtpResponse"; //The Email fputs($smtpConnect, "DATA" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['data1response'] = "$smtpResponse"; //Construct Headers $headers = "MIME-Version: 1.0" . $newLine; $headers .= "Content-type: text/html; charset=iso-8859-1" . $newLine; $headers .= "To: $nameto <$to>" . $newLine; $headers .= "From: $namefrom <$from>" . $newLine; fputs($smtpConnect, "To: $to From: $fromnSubject: $subjectn$headersnn$messagen.n"); $smtpResponse = fgets($smtpConnect, 515); $logArray['data2response'] = "$smtpResponse"; // Say Bye to SMTP fputs($smtpConnect,"QUIT" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['quitresponse'] = "$smtpResponse"; } ?>
wyswietlilem zawartosc $logArray za pomoca var_dump i otrzymalem taki wynik:
array(10) { ["connection"]=> string(43) "Connected: 220 XXXXXXXXXX ESMTP " ["authrequest"]=> string(18) "334 VXNlcm5hbWU6 " ["authusername"]=> string(18) "334 UGFzc3dvcmQ6 " ["authpassword"]=> string(28) "235 2.0.0 OK Authenticated " ["heloresponse"]=> string(26) "250 XXXXXXXXX" ["mailfromresponse"]=> string(61) "250 2.1.0 XXXXXXXXXX... Sender syntax Ok " ["mailtoresponse"]=> string(45) "250 2.1.5 XXXXXXXXX... Recipient ok " ["data1response"]=> string(46) "354 Start mail input; end with . " ["data2response"]=> string(0) "" ["quitresponse"]=> string(0) "" }
XXXXXX zaslonilem adresy email i nazwy domen. czy moze mi powiedziec czy cos jest zle?? wydaje mi sie ze cos powinno byc w ["data2response"]=> string(0) "" ["quitresponse"]=> string(0) "" ,ale pierwszy raz robie skrypt wysylajacy maile i nie wiem jakie powinny byc odpowiedzi. Z gory dzieki za pomoc. Pozdrawiam.