Trying to send mail from PHP with SMTP ?
| From: | Mukul Gandhi | Date: | Tue, 16 Nov 1999 12:49:54 +0000 |
| Subject: | Trying to send mail from PHP with SMTP ? | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-12601@lists.php.net to get a copy of this message | ||
Hi,
I am trying to run a PHP script whose code is given below. It will open a
socket to a SMTP server and send email. But this code not able to send
email. But it executes ! SMTP commands seem to be right.
------------------------------------------
$from = "MAIL FROM:<abc@pqr.com>";
$to = "MAIL TO:<mgandhi@bhartitelesoft.com>";
$from = htmlspecialchars($from);
$to = htmlspecialchars($to);
$mesg = "Just a test message";
$fp = fsockopen("smtpserver",25);
if(!$fp) {
echo htmlspecialchars("$errstr ($errno)<br>\n");
} else
{
fputs($fp,"HELO mailserver");
fputs($fp,$from);
fputs($fp,$to);
fputs($fp,"DATA");
fputs($fp,$mesg);
fputs($fp,"QUIT");
}
-------------------------------------------
I know mail() function of PHP can do this. But I am unable to work it the
above way.
Waiting for help !
regds
-mukul
--------------------------------------------------------------
Bharti Cellular Limited, New Delhi, India