Jump to content

Archived

This topic is now archived and is closed to further replies.

nadeemshafi9

trouble whith mail function

Recommended Posts

hi guys

i have read the php.net/mail() notes

i 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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.com

Now - 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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
nadeemshafi9@yahoo.co.uk

hey ken im sorry

woopie i got it it was put in to junk just know, hay man thanx alot

both you guys for your help, !!il be back!!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.