Reputation: 826
I am using the Tank Auth library for CodeIgniter. When a user is registered, the system sends them an email activation. This is working properly on my local setup, but on the live server the email is not being sent (or at least it never arrives). Emails that are automatically sent from other places - controllers that I write - using CodeIgniter's email class are being delivered as expected.
For example, this code in one of my controllers is working properly locally and on the live server:
$message = $this->load->view( 'email/email', $this->data, true );
$this->email->clear ();
$this->email->to ( $send_to );
$this->email->reply_to ( $reply_to );
$this->email->from ( $from );
$this->email->subject ( $subject );
$this->email->message ( $message );
$this->email->send ();
This code in Tank Auth sends an email on my local setup, but fails to do so on the live server:
$this->load->library ( 'email' );
$this->email->from ( $this->config->item( 'from_email' ), $this->config->item( 'site_title' ) );
$this->email->reply_to ( $this->config->item( 'reply_email' ), $this->config->item( 'site_title' ) );
$this->email->to ( $email );
$this->email->subject ( sprintf( $this->lang->line( 'auth_subject_' . $type ), $this->config->item( 'site_title' ) ) );
$this->email->message ( $this->load->view( 'email/' . $type . '-html', $data, TRUE ) );
$this->email->send ();
However, it does appear that the system thinks it is sending the email:
Your message has been successfully sent using the following protocol: mail
User-Agent: CodeIgniter
Date: Thu, 20 Oct 2011 12:30:28 -0400
From: "[redacted]"
Return-Path:
Reply-To: "[redacted]"
X-Sender: [redacted]
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <4ea04ca449b0d@[redacted]>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_4ea04ca449ef3"
[message content]
Replacing the CodeIgniter mail stuff with the following works everywhere:
$hash = md5(time());
$mime_boundary = "==Multipart_Boundary_x".$hash."x";
$headers = "From: $email->from \n" .
"Reply-To: $email->reply_to \n" .
"MIME-Version: 1.0 \n" .
"Content-Type: multipart/mixed; \n" .
" boundary=\"{$mime_boundary}\"";
$body = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type:text/html; charset=\"utf-8\"\n" .
"Content-Transfer-Encoding: 8bit\n\n".$email->message."\n\n";
mail( $email->to, $email->subject, $body, $headers );
So, obviously I have a viable work-around, but I would really like to know what is causing such a specific failure both for my future self and for others who might be coming up against the same issue.
I did find this question which seems to be about the same or a related problem but there is no answer.
UPDATE: My host poked around and found the following error related to this problem:
Oct 20 17:16:25 host qmail-scanner[26428]: Policy:Bad_MIME:RC:1(127.0.0.1)
Upvotes: 2
Views: 1589
Reputation: 26
Did you verify that each value being passed to email by Tank Auth is correct?
Also, does does send() return false?
Also, do you have any other emails being sent where you might need the: clear();
Just a thought...
OK then,
What protocol are you using? I've found that SMTP often works better for me than mail.
SMTP (or a software update) could also fix your 'Policy:Bad_MIME' issue. See: http://www.atomicorp.com/forum/viewtopic.php?f=2&t=4337
Upvotes: 1