Jump to content

How to get PHP Mail() to work more reliably.


optikalefx

Recommended Posts

I know there has got to be some server config somewhere.  But I have a site with about 8000 users.  And 20% or so can never receive "forgot email" passwords.  A lot of them checked their junk and its not there, it just never gets delivered.  But for a lot of people it works fine.

 

So... How can i get PHP mail() to work better.

 

Right now im using swift mailer with this code

 

function email($to,$subject,$body,$from="") {
	require_once 'packages/swift/swift_required.php';
	$transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');
	$mailer = Swift_Mailer::newInstance($transport);
	$message = Swift_Message::newInstance($subject);
	$message->setFrom($from);

	$headers = $message->getHeaders();
	if (!$headers->has('Reply-To')) {
	  $headers->addTextHeader('Reply-To',$from);
	}

	if(!is_array($to)) $to = array($to);
	$message->setTo($to);
	$message->setBody($body,'text/html');
	$result = $mailer->batchSend($message);
	$toString = implode(",",$to);
	$this->_log("EMAIL to $toString - $body - $result");
	return $result;
}

 

What have you guys used for this kind of thing? Is there some server config everyone should do?

Thanks!

Hi,

i suggest you to use PHPMailer

PHP email transport class featuring multiple file attachments, SMTP servers, CCs, BCCs, HTML messages, and word wrap, and more.

 

It can send email via sendmail, PHP mail(), or with SMTP. Methods are based on the popular AspEmail active server component.

 

Update:

But swiftMailer also a good choice or even better - http://forums.phplist.com/viewtopic.php?t=8270

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.