Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/articles/php-tutorials/)
-   -   Using Sendmail in PHP (http://www.go4expert.com/articles/using-sendmail-php-t465/)

pradeep 14Oct2005 13:21

Using Sendmail in PHP
All PHP coders are aware of the mail() function in PHP, which can be used to send mails. On Linux systems we ussually have Sendmail program installed, if someone is facing a problem sending mails with mail() function, they can alternatively use Sendmail to send mails.
For sending mails using Sendmail we need to open a pipe to the sendmail program, which can be accomplished using the popen() function in php.

PHP Code:

    $fd popen("/usr/sbin/sendmail -t","w") or die("Couldn't Open Sendmail");
fputs($fd"To: recipient@hisdomain.com \n");
fputs($fd"From: \"Your Name\" <youremail@yourdomain.com> \n");
fputs($fd"Subject: Test message from my web site \n");
fputs($fd"X-Mailer: PHP3 \n\n");
fputs($fd"Testing. \n");

dj_buddhika 7Dec2006 12:09

Re: Using Sendmail in PHP
do you know this is cannot send emails to hotmail or yahoo accounts.
How to make it success

pradeep 7Dec2006 13:11

Re: Using Sendmail in PHP
May be your IP is in the not-trusted list. Check your IP for a block here http://www.spamhaus.org/sbl/index.lasso

manilodisan 11Dec2006 02:56

Re: Using Sendmail in PHP
hotmail, aol and some others have huge problems in receiving the emails due to their spam filters. I would recommend sending emails via SMTP

manilodisan 11Dec2006 02:57

Re: Using Sendmail in PHP
Or...a fresh IP of the server :))

All times are GMT +5.5. The time now is 14:12.