nadeemshafi9 Posted April 1, 2006 Share Posted April 1, 2006 hi guysi have read the php.net/mail() notesi am having trouble figuring out why my program says successfull and mail() returns true yet the email is not sent.i know you need access to the sendmail binary, but how do i do this and how do i check if it is done.im on easyspace starter pack server, its linux whith apachie and php.hers my code[code]<?php if(mail("nadeemshafi9@hotmail.com", "hi", "hello", "info@DICECONSULTING.com")) { print "successfull"; } else { print "ERROR - not sent"; } ?>[/code]thanks all for any sugestions. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 1, 2006 Share Posted April 1, 2006 The success returned from the mail() function just means that the message was successfully sent to the email program on your host, not that it was sent successfully to your recipient.You're sending to a Hotmail account. Hotmail is notorious for filtering out what it thinks is spam and sometimes dropping the message into the bit bucket without telling either the sender or intended reciever. It usually does this when the domain name in the "Return-path:" header doesn't match the domain name in the "From:" header. The "Return-Path:" header can be set to the correct domain by using the fifth parameter to the mail() function. Assuming the domain you are sending from is "diceconsulting.com", here's how to use it:[code]<?php $to = 'nadeemshafi9@hotmail.com'; $subj = 'hi'; $body = 'hello'; $headers = "info@diceconsulting.com\n"; $p5 = '-f info@diceconsulting.com'; if(mail($to,$subj,$body,$headers,$p5)) { print "successfull"; } else { print "ERROR - not sent"; }?>[/code]You'll notice that I put all the parameters to the mail() function in variables -- just my preference. And I put all domain names in lowercase.Ken Quote Link to comment Share on other sites More sharing options...
steviewdr Posted April 1, 2006 Share Posted April 1, 2006 Here's my two cents on mail()firstly, as kenrbnsn said, the full mail() is:mail($to,$subj,$body,$headers,$fail_bounce)where $fail_bounce= "-f email_bounces_address@whatever.com"if your email is sent, and if it bounces or does not get delivered, because of a bad email address then, the email will be bounced back to email_bounces_address@whatever.comNow - if your php mail() is NOT working at all: you will have to test it out.Do you have ssh (login) access to the webserver?Mail logs are kept in /var/log/mail.info All emails sent and recieved are logged to this file. I doubt you will have permission however to read these logs.Depending on what MTA (sendmail etc.) is on the server, if you have ssh access - you can bypass php's mail() and test if emails CAN actually be sent from your server -> how to test sendmail: [a href=\"http://wiki.kartbuilding.net/index.php/Sendmail\" target=\"_blank\"]http://wiki.kartbuilding.net/index.php/Sendmail[/a]If all that fails - then to a phpinfo() and check your mail settings in it.You may have to use your own Mail server to send emails.Best of Luck tracing the problem.-steve Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted April 1, 2006 Author Share Posted April 1, 2006 hi again guys thanks for the response i was hoping that what you said would resolve it , but the way most of these things go, it whants more.ok whats happiening is still the same its not getting sent and its not bouncing, so i think its not getting off the server at all, please take a look at my phpinfo()[a href=\"http://diceconsulting.com/phpinfo.php\" target=\"_blank\"]http://diceconsulting.com/phpinfo.php[/a]i found 2 peices relating to the mail the path to sendmail and from.they havent given me ssh access so i cant ssh to the server.i thiink we are getting close, its not the latest php its v4 im used to v5 oop, but still mail is the same on both and id prob hav same prob on both 4 and 5.thanx again for any help Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 1, 2006 Share Posted April 1, 2006 Do you have a test address you can use that is not an Hotmail address? If not, I will send you my email address via a PM.Ken Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted April 1, 2006 Author Share Posted April 1, 2006 nadeemshafi9@yahoo.co.ukhey ken im sorry woopie i got it it was put in to junk just know, hay man thanx alotboth you guys for your help, !!il be back!! Quote Link to comment 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.