Forum Moderators: coopster

Message Too Old, No Replies

sending email

troubles

         

gforgyro

2:17 pm on Dec 29, 2006 (gmt 0)

10+ Year Member



I tried the following posted by Nickoons and get a parse error: unexpected T-string in this line -
$SMTP = fsockopen("mail.example.org", 25);

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]

IanKelley

10:29 pm on Dec 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The line where the error is showing up is not the actual location of the error. You have a basic formatting error somewhere further up in the script.