cannot send email through php

Discussion in 'Programming' started by newbie8899, Jan 11, 2008.

  1. #1
    Hi, all.. i have a big problem here. I wish to send email through the php script.. but i don know what's wrong with it. it stated there email sent.. but i cannot receive any email. Can anybody tell me what probably did i do wrong? is it that i need to install other thing to run smtp? below is my test script which i use to test send the email.

    
    <?php
    //define the receiver of the email
    $to = 'email address here';
    //define the subject of the email
    $subject = 'Test email'; 
    //define the message to be sent. Each line should be separated with \n
    $message = "Hello World!\n\nThis is my first mail."; 
    //define the headers we want passed. Note that they are separated with \r\n
    $headers = "From:(E-Mail address blocked: See forum rules)\r\nReply-To: sender email address here";
    //send the email
    $mail_sent = @mail( $to, $subject, $message, $headers );
    //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" 
    echo $mail_sent ? "Mail sent" : "Mail failed";
    ?>
    
    
    PHP:
    after i run the script, the browser showing Mail sent. but when i check my email account, i did not receive any of this email.
     
    newbie8899, Jan 11, 2008 IP
  2. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #2
    Check your spam/bulk box.

    Remove the @ before mail, it will show any errors if any.

    Peace,
     
    Barti1987, Jan 11, 2008 IP
  3. Mr_Kumar

    Mr_Kumar Notable Member

    Messages:
    2,561
    Likes Received:
    374
    Best Answers:
    1
    Trophy Points:
    265
    Articles:
    4
    #3
    I am only seeing one problem which azizny has mentioned.

    Remove @ from line:

    $mail_sent = @mail( $to, $subject, $message, $headers );
     
    Mr_Kumar, Jan 12, 2008 IP
  4. neds75

    neds75 Peon

    Messages:
    201
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Maybe your smtp server request authorization, before you send email?
    Did you try to send email without headers, to see if it will pass?
     
    neds75, Jan 13, 2008 IP
  5. newbie8899

    newbie8899 Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I've tried every thing but still the same..

    can i ask what should i put in php.ini file for this : SMTP =

    I am currently putting it as SMTP = smtp.streamyx.com. coz in malaysia, i m using streamyx isp now.. is it correct?.. i really have no idea what to put there..
     
    newbie8899, Jan 13, 2008 IP
  6. Dman91

    Dman91 Peon

    Messages:
    46
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    many of my friends have got this problem ... try using the email of ur webserver... something like
     
    Dman91, Jan 14, 2008 IP
  7. neds75

    neds75 Peon

    Messages:
    201
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    No, that is just address of your smtp server. If it is on same server like your web server, it will works with:
    SMTP = localhost

    But it is possible that sendmail(I suppose that your company is using it), you might need to enter location of it:
    sendmail_path =

    Also it could be possible that your hosting company use differnt smtp server(like postfix.

    I suggest you to contact them and ask for details how to send emails from php. But I still think that it might be due to authorisation issue.

    Thanks,
    Ivica
     
    neds75, Jan 14, 2008 IP
  8. wmtips

    wmtips Well-Known Member

    Messages:
    601
    Likes Received:
    70
    Best Answers:
    1
    Trophy Points:
    150
    #8
    There are could be delivering problems if you have wrong DNS configuration. For example Hotmail, Yahoo and AOL require you to have reverse DNS properly configured. Some more
     
    wmtips, Jan 14, 2008 IP
  9. rkquest

    rkquest Well-Known Member

    Messages:
    828
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    140
    #9
    It doesn't matter if he wants to hide the error messages, he's using a variable to detect if it is sent or not anyways. The message "Message Failed" should print if there was an error and the thread starter said he gets "Message Sent". If he removes @ I bet he'll get the same result.

    I suggest you check your spam box. Still if it's not there, send the message to different addresses using a different providers. If non of them were able to receive the message, you should contact your hosting provider.
     
    rkquest, Jan 14, 2008 IP