Jump to content

sendmail: 451 internal error


rohitbanerjee

Recommended Posts

Hello,

 

I am using the Pear Mail and Mail_Mime packages to send SMTP authenticated HTML formatted emails. I was successfully sending emails when I started getting the following error:

 

sendmail: 451 Internal Error

 

I check out the sendmail logs at /var/log/mail.log but that only says the same thing.

 

I am running Linux-Ubuntu and sending emails from an address on a remote server (godaddy hosted). The interesting thing is that this exact same code will run to completion and fail.

 

Any thoughts? Anyone with Pear Mail experience, is there any way to  end the SMTP session, maybe that is the problem. I also think an issue might be that the server thinks my IP is sending too many emails, any way to provision against that?

 

Thanks for any insight and please let me know if other information might be helpful to debug this.

Link to comment
Share on other sites

My, this is popular just now...

First and best thing to do is check the go-daddy documentation to see if there is deffinition of the error code in their mail settings/support pages.

 

If that fails I wrote a function for sending mail through the PEAR Net_SMTP class which returns the full server response array, code and description (assuming the server provides one) which you can find here: http://www.phpfreaks.com/forums/index.php?topic=351896.0 if you use that for debug then you will be quickest doing a vardump on the return.

Link to comment
Share on other sites

check the order that you are passing the variables into the function, it should be set for HTML messages and generic binary data attachments (octet-stream).  I have it in use here and the emails have the html contnent that I expect with xml attachments (having altered the content-type for the attachment).  Read through the comments in the function, they should help you see what's happening where.

Link to comment
Share on other sites

Yeah, I figured that I was doing that wrong and I got it working -- I am now getting the following error code:

503 You must send mail FROM: first but my emails are getting formatted as follows:

 

From: name <example@domain.com>

To: <recipient@otherdomain.com>

Subject: Test Subject

Reply-To: example@domain.com

MIME-Version:1.0

Content-type:text/html;charset="iso-8859-1";

 

I've pasted the modified source below

function sendSMTP($subject, $body, $user, $pass, $to, $destination, $from, $sender, $fName, $attachment=null){
$e = "\n"; //end of line
//$bound= "==rbanerjee_".md5(time()); //create a unique boundary for this mail to separate each different type in the message. 

@$smtp = new Net_SMTP("smtpout.secureserver.net", 80); // set to youe mail providers A record and port number (IP Addresses will also work for server)
@$smtp->connect(60); //create connection and set timeout duration
@$smtp->helo('domain.ext'); //start comunication with server --change to your mail providers domain   
@$smtp->auth($user, $pass);  //authenticate account
@$smtp->mailFrom("$sender");  //email address of authenticated account, can set default in function declaration
@$smtp->rcptTo("$destination");   //recipient of mail, can set default in function declaration

$header = "";  //set header as empty 
$header = "From: $from <$sender>".$e; // Set Friendly Name and address of sender
$header .= "To: <$destination>".$e; // Set Friendly name and address of recipient
$header .= "Subject: $subject".$e;  //Set mail Subject
$header .= "Reply-To: $sender".$e;  //Set Reply-to address
$header .= 'MIME-Version:1.0'.$e;   //use MIME transport
$header .= "Content-type:text/html;";  //set contnent as html for mail body
$header .= "charset=\"iso-8859-1\";".$e; //set charactor set to be used in mail body - can be changed to suit
//echo $header . "\n"; exit(0);
$message = $header; //include headers into message information
$message .= $body.$e.$e; //add the contnent of $body which is passed into the function 

//$message .= "--$bound--".$e; //closing boundary shows it's the last part of the MIME and the mail is now complete

@$smtp->data($message); //send message to the server
$msg = $smtp->getResponse(); // get server response array format -- $msg = Array([0]=>'server numeric code' [1]=>'Text message from server for code') -- hMailServer success response code is 250.  This can be called after any of the $smtp-> calls for error capture 
@$smtp->disconnect(); // close server connection
return $msg; //pass out server response array
}    

 

with domain.ext replaced with my domain -- It seems like a formatting issue but I haven't made any major changes to your format have I?

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.