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
Share on other sites

I solved the problem, but going to leave this up for posterity

 

$to = 'you@you.com';$from = 'yourself@you.com';$subject = '!New Claim!';
		$host = "smtp.com";$musername = "techteam@you.com";$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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.