ERMIS Posted December 19, 2010 Share Posted December 19, 2010 Hello All, I need your help on this matter, please... I used to use the following code to send emails through authenticated SMTP server and it was working fine, however when the SMTP server has been changed from "IAMP4" to "POP" the code stopped sending emails, please hep. The code is: function authSendEmail($from, $namefrom, $to, $nameto, $subject, $message, $message2, $message3) { //SMTP + SERVER DETAILS /* * * * CONFIGURATION START * * * */ $smtpServer = "sever name"; $port = "port#"; $timeout = "30"; $username = "username"; $password = "password"; $localhost = "localhost"; $newLine = "\r\n"; /* * * * 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 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit; Content-type: text/html; charset=iso-8859-1 $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\nFrom: $from\nSubject: $subject\n$headers\n$message\n\n$message2\n\n$message3\n.\n"); $smtpResponse = fgets($smtpConnect, 515); $logArray['data2response'] = "$smtpResponse"; // Say Bye to SMTP fputs($smtpConnect,"QUIT" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['quitresponse'] = "$smtpResponse"; } Please help me... Link to comment https://forums.phpfreaks.com/topic/222149-cannot-send-emails-after-changing-server-from-iamp-to-pop/ Share on other sites More sharing options...
ERMIS Posted December 27, 2010 Author Share Posted December 27, 2010 Found the solution I was just a matter of putting angle brackets around $from and $to !!! Link to comment https://forums.phpfreaks.com/topic/222149-cannot-send-emails-after-changing-server-from-iamp-to-pop/#findComment-1151867 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.