Jump to content

trouble whith mail function


nadeemshafi9

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.