views:

50

answers:

2

I am facing an issue where in, i am not able to send emails if the email body has more than 70 chars! The site is hosted on godaddy.

SMTP host : relay-hosting.secureserver.net

SMTP port : 25

For message body < 70 chars i get a SMTP reply code of 250 as expected. But anything > 70 gives a reply code 451 which means "Requested action aborted: local error in processing" and am not able to figure out why! =(

I am using this SMTP class with which i have been able to send mails from godaddy earlier (with a different SMTP credentials)

/**
 * Wrapper function for SMTP class
 */
function sendEmail($to, $from, $subject, $message ,$ishtml = null,  $headers = null)
{
    global $_CONFIG;
    $smtp = new SMTP($_CONFIG['email_host'], $_CONFIG['email_port'], false, 5);
    if($ishtml)
    {
        $smtp->set_html();
    }
    $extraHeader = null;
    if(is_array($headers))
    {
            $extraHeader = array(
            'CC' => $headers['CC'],
            'BCC'=> $headers['BCC']
        );  
    }
    else
    {
        $headers = null;
    }

    # Who is this email from? (MAIL FROM header)
    $smtp->mail_from($from);

    # Sending the email
    $isSent = $smtp->send($to, $subject, $message, $ishtml, $extraHeader);
    //var_dump($smtp->error());exit;
    return $isSent;
}

Function call:

$subject = "Thanks you for registering";
$from = '[email protected]';
$to = $regFormData['email'];
$message = "Thanks you for registering.You have registered  with the following details";
$sendStatus = sendEmail($to, $from, $subject, $message ,false, $headers);
//$sendStatus returns false and SMTP relay code is 451

The SMTP relay is avaliable for all godaddy hostings. Could it be that they have some kind of restriction?

Any inputs are appreciated! Thanks.

--Just received a reply from godaddy support. "We do not place any restriction on your email message character length, and it is possible that the problem is due to something in the code."

+1  A: 

Wrap the body with PHP wordwrap:

$message = wordwrap($message, 70, "\n", TRUE);
Lekensteyn
hey Lekensteyn, thanks for the quick reply! I tried this out.. however doesn't seem to make any difference!
Sheldon Ferns.
A: 

Try changing other elements of the email (eg To: address) and see if it's actually a limit on the overall message size not on the body itself - eg does a longer email address/subject result in a shorter body that works?

It's possible you're hitting some sort of packet size issue - perhaps we can track it down if we get a little more information

Basiclife
Hi Basiclife, i tried changing the subject length. There doesnt seem to be any restriction on subject length. I thk we can rule out packet size.. Anything else that i can chk for ?
Sheldon Ferns.
Ok, I' normally suggest we connect to the SMTP server manually and attempt to send a message but from your comment on the OP, I'm guessing this is what the new smtp module you got does? If not, please telnet to the smtp server and send some smtp commands manually (see here http://www.yuki-onna.co.uk/email/smtp.html ). Otherwise, skip that and read through this: http://forums.oscommerce.com/topic/62828-smtp-email-451-error/ - try using \r\n instead of \n.
Basiclife
if \r\n works and \n doesn't, it seems like it's a server config issue. If not, we'll try something else :)
Basiclife
Sheldon Ferns.
You're welcome :)
Basiclife