suyesh.amatya Posted July 31, 2008 Share Posted July 31, 2008 <? ini_set('smtp_port','25'); if(mail("abc@hotmail.com","hi","test mail")) echo 'success'; else echo 'failed'; ?> With this script i am not being able to send the mail...is there anything wrong here??? Quote Link to comment https://forums.phpfreaks.com/topic/117485-php-mail/ Share on other sites More sharing options...
JonnoTheDev Posted July 31, 2008 Share Posted July 31, 2008 Add mail headers. Also I have sometimes had to use the -f switch (see mail() function) on certain web hosts $from = "me@mydomain.com"; $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/plain;\r\n"; $headers .= "X-Priority: 3\n"; $headers .= "X-MSMail-Priority: Normal\n"; $headers .= "X-Mailer: php\n"; $headers .= "From: \"My Company\" <".$from.">\n"; $headers .= "Reply-To: \"My COmpany\" <".$from.">\n"; mail("to@whoever.com","subject","message",$headers,"-f".$from); Quote Link to comment https://forums.phpfreaks.com/topic/117485-php-mail/#findComment-604330 Share on other sites More sharing options...
JonnoTheDev Posted July 31, 2008 Share Posted July 31, 2008 Check your mail log to see if the message is gone. Linux: cat /var/log/maillog Quote Link to comment https://forums.phpfreaks.com/topic/117485-php-mail/#findComment-604332 Share on other sites More sharing options...
suyesh.amatya Posted July 31, 2008 Author Share Posted July 31, 2008 if i dont have any mail server, cant i send the mail with this php mail function.. i think it should have been sent by just using the mail function. Quote Link to comment https://forums.phpfreaks.com/topic/117485-php-mail/#findComment-604339 Share on other sites More sharing options...
JonnoTheDev Posted July 31, 2008 Share Posted July 31, 2008 Never tried from a standalone pc! Always developed on *nix systems. Mail server would be sendmail or exim, etc.. Check out mail() on php.net If you are a windows user: The Windows implementation of mail() differs in many ways from the Unix implementation. First, it doesn't use a local binary for composing messages but only operates on direct sockets which means a MTA is needed listening on a network socket http://uk2.php.net/manual/en/function.mail.php Quote Link to comment https://forums.phpfreaks.com/topic/117485-php-mail/#findComment-604341 Share on other sites More sharing options...
Orionsbelter Posted July 31, 2008 Share Posted July 31, 2008 try this tell me if it works $subject = "[sUBJECT HERE]"; $message = "[MESSAGE HERE]"; mail([email HERE], $subject, $message, "From: [YOUR NAME HERE]"); echo 'A Email has been sent to [email HERE]'; [code] [/code] Quote Link to comment https://forums.phpfreaks.com/topic/117485-php-mail/#findComment-604345 Share on other sites More sharing options...
suyesh.amatya Posted July 31, 2008 Author Share Posted July 31, 2008 doesnt work either...how can sending a simple mail be so complicated/// Quote Link to comment https://forums.phpfreaks.com/topic/117485-php-mail/#findComment-604350 Share on other sites More sharing options...
JonnoTheDev Posted July 31, 2008 Share Posted July 31, 2008 You musn't have any MTA (mail transfer agent). See my post above. If you are using Outlook on your PC you have to setup a mail account i.e. POP3 suppliying a mail server, username, password, etc so you can send & receive mail. The php mail function() cannot guess this for you! Quote Link to comment https://forums.phpfreaks.com/topic/117485-php-mail/#findComment-604360 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.