Jump to content

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


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);

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

	if(!is_array($to)) $to = array($to);
	$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?


Link to comment
Share on other sites


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.



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

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.

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.