Zeradin Posted June 22, 2010 Share Posted June 22, 2010 I can't believe I can't find a problem similar to this on the internet. After 1024 characters, my mail messages fail. I'm using pair. I tried adding \n 's and \r's to no avail. I get the following error code: Failed to send data [sMTP: Invalid response code received from server (code: -1, response: )] I know if I get the characters down to like 984 it succeeds and sends. What gives? Link to comment https://forums.phpfreaks.com/topic/205570-mail-fails-when-body-is-over-1024-char/ Share on other sites More sharing options...
kenrbnsn Posted June 22, 2010 Share Posted June 22, 2010 Code? Link to comment https://forums.phpfreaks.com/topic/205570-mail-fails-when-body-is-over-1024-char/#findComment-1075694 Share on other sites More sharing options...
Zeradin Posted June 22, 2010 Author Share Posted June 22, 2010 I solved the problem, but going to leave this up for posterity $to = '[email protected]';$from = '[email protected]';$subject = '!New Claim!'; $host = "smtp.com";$musername = "[email protected]";$mpassword = "pass"; $crlf = '\n'; $mime = new Mail_mime($crlf); $html = 'Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim... '; $html .= 'Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim... '; $html .= 'Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim... '; $html .= 'Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim... '; $html .= 'Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim...Hey, there\'s a new claim... '; $hdrs = array( 'From' => $from, 'Subject' => $subject ); $mime->setHTMLBody($html); $body = $mime->get(); $hdrs = $mime->headers($hdrs); $smtp =& Mail::factory('smtp', array('host'=> $host, 'auth' => true, 'username' => $musername, 'password' => $mpassword)); $mail = $smtp->send($to, $hdrs, $body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo(""); } the problem was: $crlf = '\n'; needs to be $crlf = "\n"; because php doesn't interpret the single quotes as a line break. so it was getting the mail in one huge string that was too long for it to handle. Link to comment https://forums.phpfreaks.com/topic/205570-mail-fails-when-body-is-over-1024-char/#findComment-1075698 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.