Alternate way of e-mailing in PHP

From: Date: Mon, 05 Jan 2004 06:38:09 +0000
Subject: Alternate way of e-mailing in PHP
Groups: php.general 
Request: Send a blank email to php-general+get-173729@lists.php.net to get a copy of this message
I've been getting "data format errors" from Sendmail when trying to send automatic e-mails from my websites recently, and as I can't find a fix for this, I tried some code that someone sent to me which actually worked. It uses popen() and I'd like to know if this method of sending e-mail has any major drawbacks over using the PHP mail() command (which doesn't work for me anymore). Here's the code: -------- $messg = "Here we put the content of the message."; $sender = "me@myserver.com"; $sendmail = "/usr/sbin/sendmail -t -f $sender"; $body = "This is a test."; $fd = popen($sendmail, "w"); fputs($fd, "To: someone@domain.com\r\n"); fputs($fd, "From: \"Sender Name\" <$sender>\r\n"); fputs($fd, "Subject: Finally\r\n"); fputs($fd, "X-Mailer: Mailer Name\r\n\r\n"); fputs($fd, $body); pclose($fd);

« previous php.general (#173729) next »