Welcome Guest, Not a member yet? Register   Sign In
Inconsistent Mail Error on Server: "Unable to send email using PHP mail()"

So - I am having a really weird issue! I am trying to send an email with Codeigniter's Email Library. It works fine locally, but for some reason I keep getting the following error when I test it live on my Lunarpages server:
Quote:Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.

Here's where it gets really weird - the code I am using is almost identical to what I am using in another Controller on another part of this very server - and the mail works fine there! The <b>only difference</b> is that this new Controller is on a <b>domain parked to a subdirectory</b> of this same server, whereas the original controller is on the <b>main directory and main domain</b> of the server. The only thing I can imagine is that this is causing the problem. Hopefully somebody has some clues here that understands SMTP better than I. Here is the code:

$config['mailtype'] = 'html';
$this->email->from('[email protected]', 'Testing From');
//To the business contact from listing array
$this->email->subject('New rental reservation request');
$this->email->message('<center><img src="'.config_item('img_base').'new_rental_lead.png"/></center><strong>Customer name: </strong>'.$_POST['first_name'].' '.$_POST['last_name'].br().'<strong>Delivery address:</strong> '.br().$_POST['delivery_address'].br().$_POST['delivery_city'].', '.$_POST['state_prefix'].' '.$_POST['delivery_zip'].br().'<strong>Phone number:</strong> '.$_POST['phone_number'].br().'<strong>Email:</strong> '.$_POST['email'].br().'<strong>Estimated Event Date:</strong>'.$_POST['date'].br().'<strong>Estimated Number of Guests:</strong> '.$_POST['guests']);    

echo $this->email->print_debugger();

Any help would be greatly appreciated! If you need clarification on this, don't hesitate to ask.

I have had similar problems in the past and it turned out they had to do with address resolution (dns).

My guess is that the server is looking for an smtp server in a place where it doesn't exist. Because it does work on other ("full") domains, I would say that probably the dns settings for such a full domain are different from your parked domain. And so, when it tries to send a mail through smtp.yourparkeddomain.com, the server says 'hey, I can't find that smtp server'.

So, the resolution might be in checked / altering your server's dns settings as to provide php with an smtp server that is local to your parked domain.
Or change the php settings to look for an smtp server on another (fully functional) domain. But then you will have to check if the server accepts mail from your parked domain, because it is good practice not to let smtp servers accept mail from anywhere because of the risk of abuse.

Thank you!

As it turned out, in my case it was a simple error. The $to email was blank. Unfortunately, the Codeigniter Mail() debugger does not provide the specific cause of the error. Be careful!

Theme © iAndrew 2016 - Forum software by © MyBB