rohitbanerjee Posted March 15, 2012 Share Posted March 15, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/258993-sendmail-451-internal-error/ Share on other sites More sharing options...
Muddy_Funster Posted March 15, 2012 Share Posted March 15, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/258993-sendmail-451-internal-error/#findComment-1327702 Share on other sites More sharing options...
rohitbanerjee Posted March 15, 2012 Author Share Posted March 15, 2012 Hey Muddy, Seems you and I are going to get to know each other pretty well Thanks for the insight, I'll try it out and post how it goes. Rohit Quote Link to comment https://forums.phpfreaks.com/topic/258993-sendmail-451-internal-error/#findComment-1327705 Share on other sites More sharing options...
rohitbanerjee Posted March 15, 2012 Author Share Posted March 15, 2012 Hey Muddy, So your code is working -- however, because I am sending html formatted emails, they are arriving as html attachmetns. What would I change to set the body of the email as the html formatted message. Thanks, Quote Link to comment https://forums.phpfreaks.com/topic/258993-sendmail-451-internal-error/#findComment-1327726 Share on other sites More sharing options...
Muddy_Funster Posted March 15, 2012 Share Posted March 15, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/258993-sendmail-451-internal-error/#findComment-1327737 Share on other sites More sharing options...
rohitbanerjee Posted March 15, 2012 Author Share Posted March 15, 2012 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 <[email protected]> To: <[email protected]> Subject: Test Subject Reply-To: [email protected] 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? Quote Link to comment https://forums.phpfreaks.com/topic/258993-sendmail-451-internal-error/#findComment-1327782 Share on other sites More sharing options...
rohitbanerjee Posted March 15, 2012 Author Share Posted March 15, 2012 NVM, was logging incorrectly Quote Link to comment https://forums.phpfreaks.com/topic/258993-sendmail-451-internal-error/#findComment-1327843 Share on other sites More sharing options...
Muddy_Funster Posted March 16, 2012 Share Posted March 16, 2012 glad it's working for you. Quote Link to comment https://forums.phpfreaks.com/topic/258993-sendmail-451-internal-error/#findComment-1327994 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.