mail() function

Discussion in 'PHP' started by Danago, Oct 14, 2006.

  1. #1
    Hey. For some reason, the mail function wont work properly on my website. This is exactly what i have:
    
    mail("danago@iprimus.com.au", "Subject", "message");
    
    PHP:
    And it is not working. I am not recieving any email. Ive never had problems like this before.

    Can anyone tell me why it may not be working? Will be it something to do with the server on which i am hosted?

    Thanks,
    Dan.
     
    Danago, Oct 14, 2006 IP
  2. streety

    streety Peon

    Messages:
    321
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You have no doubt already thought about this but your message may be getting caught as spam. If you do have some anti-spam tools in place it would be worthwhile checking to see if your emails have been caught.

    Have you looked at the return value from the mail function? It is normally useless but may give a hint as to whether your message is being sent and lost or just not sent.

    Failing that your code looks fine to me and the only thing I can suggest it contacting your web host.
     
    streety, Oct 14, 2006 IP
  3. Danago

    Danago Active Member

    Messages:
    106
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #3
    Yea im sure that its not being counted as spam.

    To find the return value, would this be sufficient?
    
    echo mail("danago@iprimus.com.au", "Subject", "message"); 
    
    Code (markup):
    If so, i get a value of 1, which in my understanding, means true.
     
    Danago, Oct 14, 2006 IP
  4. Morishani

    Morishani Peon

    Messages:
    239
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    If you like results like 1, if you don't you can use a simple if sentence :
    
    if (mail("danago@iprimus.com.au", "Subject", "message"))
     {
     echo "Mail sent";
     }
    else
     {
     echo "Error while sending mail";
     }
    
    Code (markup):
     
    Morishani, Oct 14, 2006 IP
  5. streety

    streety Peon

    Messages:
    321
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yep so according to that the mail was sent without any problems and if it isn't being caught by a spam filter all I can suggest is that you contact your web host.
     
    streety, Oct 14, 2006 IP