Forum Moderators: coopster
I am new to all this and desperately need help. What am I doing wrong? Anyone - Please!
I had the same issue. My old server worked fine.. and when I migrated the site to its own dedicated box, this function stopped working even though sendmail was working just fine. I also noticed that PHP's mail() function is very slow. I run a mailing list, and I created a web-based system to manage and deploy all of these emails.
I ended up creating my own function to replace PHP's mail() function, which A) works on my new system, and B) is many times faster than PHP's mail() function. Here it is, in case you'd like to use it. It uses sockets to connect directly to the SMTP server of your choice:
function SendMail($ToName, $ToEmail, $FromName, $FromEmail, $Subject, $Body, $Header)
{
$SMTP = fsockopen("smtp.sitename.com", 25);
$InputBuffer = fgets($SMTP, 1024);
fputs($SMTP, "HELO sitename.com\n");
$InputBuffer = fgets($SMTP, 1024);
fputs($SMTP, "MAIL From: $FromEmail\n");
$InputBuffer = fgets($SMTP, 1024);
fputs($SMTP, "RCPT To: $ToEmail\n");
$InputBuffer = fgets($SMTP, 1024);
fputs($SMTP, "DATA\n");
$InputBuffer = fgets($SMTP, 1024);
fputs($SMTP, "$Header");
fputs($SMTP, "From: $FromName <$FromEmail>\n");
fputs($SMTP, "To: $ToName <$ToEmail>\n");
fputs($SMTP, "Subject: $Subject\n\n");
fputs($SMTP, "$Body\r\n.\r\n");
fputs($SMTP, "QUIT\n");
$InputBuffer = fgets($SMTP, 1024);
fclose($SMTP);
}
I believe I've modified the script sufficiently that it doesn't include anything specific to my configuration.. I apologize if I haven't. You'll need to replace "smtp.sitename.com" and "sitename.com" with your server's information.
[edited by: coopster at 2:12 am (utc) on Dec. 30, 2006]
[edit reason] generalized domain in fsockopen function [/edit]