LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   mail() function in php (https://www.linuxquestions.org/questions/linux-newbie-8/mail-function-in-php-877087/)

ramzaher 04-26-2011 01:06 AM

mail() function in php
 
hey,my mail() function dsn't work ! i have configure the php.ini ;
<code>For Unix only. You may supply arguments as well (default: "sendmail -t -i").
http://php.net/sendmail-path
sendmail_path = /usr/sbin/sendmail
<code>


and the script is simple
<code>
<?php

include('Mail.php');
include('Mail/mime.php');
$to = "ram_mere@yahoo.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "ram_blueeagle@hotmail.com";
$headers = "From:" . $from;

if(mail($to,$subject,$message,$headers))
{
echo "Mail Sent.";
}
else
{echo "fail";}
?>
</code>

i got fail always ! :( anyHelp

koosha 04-26-2011 04:44 AM

You need to have a valid SMTP server set in your PHP environment. Either your local one or the one that you intend to send your mail to can be used. The latter is preferable, i.e. Yahoo's mail server if you want your mails to be sent only to yahoo. But if you want to send your mails to any server, you have to setup a valid SMTP server on your machine.

ramzaher 04-27-2011 12:59 PM

actually i did every thing ,how i should validate SMTP server ?? i have downloaded postfix and did every thing ,when i sent email (from the localhost) i got nothing in hotmail or yahoo of gmail !

sophist114 04-29-2011 02:00 AM

Hey,buddy,i run into the same problem you faced, it seems php main() function doesn't work at all,i tried the same as you did
But when i'm using zend_mail, a component of zend framework, it works nice! My suggestion to you is go and look up zend_mail in detail, it might explain the whole thing.

sophist114 04-29-2011 02:03 AM

BTW, does any of worked with DMdelivery before? i got a problem with it for days. can you contact me if you have experienced with DMdelivery?


All times are GMT -5. The time now is 01:52 PM.