Jump to content

Mail Fails when body is over 1024 char


Zeradin

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.