Mail function is not working in different server

Discussion in 'PHP' started by junandya, Jan 25, 2008.

  1. #1
    Hi,

    i have two servers, server A in holland and server B in indonesia, in server A i store this basic mail script
    <?php
    $kepada   = "bobby2000008@yahoo.com";
    $subject  = "hello, how are you...";
    $isi      = "This is bobby\n\n";
    $isi     .= "Dear Mr Bobby \n\n";
    $isi     .= "i know you are: \n";
    $isi     .= "Name: bobby \n\n";
    $isi     .= "U R a good guy \n\n";
    $kirimke  = "From:bobby angel <bobbycool08@yahoo.com>";
    $kirimke .= "Reply-To:bobbycool08@yahoo.com";
    $email    = mail($kepada,$subject,$isi,$kirimke);
    if ($email)
    	{
    		echo "Sent properly";
    	}
    else
    	{
    		echo "failed..failed...failed";
    	}
    ?>
    PHP:

    Also in server A i've installed simple machince forum, from http://www.simplemachines.org.

    The situation is like this:
    1. the script above where stored in server A is not working, i mean i never receive every email that should be sent when i run the script.

    2. i try to register to the forum that specified in server A, it's working, i mean the email notification from this forum was sent (i receive it) with the same email address as used in script above.

    3. when i store that script above to server B, it is running properly, i mean i always receive every email that sent when i runned the script.


    My quertion is:
    1. Could some one explain me what is the problem exactly, i really dont understand about this.
    2. is this probably about the setting of server A?
    3. Is there something wrong with the script specified?
    4. is there a relationship with .htaccess?

    Thank you B4
     
    junandya, Jan 25, 2008 IP
  2. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Is the SMF using SMTP or the PHP Mail() function? Your sendmail path may be configured incorrectly.

    Jay
     
    jayshah, Jan 25, 2008 IP
  3. junandya

    junandya Member

    Messages:
    79
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #3
    1. But why it is working properly in server B?
    2 can you explain me please, what do you mean with 'Your sendmail path may be configured incorrectly'.
     
    junandya, Jan 25, 2008 IP
  4. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #4
    Hello,

    Sendmail is what PHP uses to send emails. You should check your error logs to see if any errors have been encountered.

    Jay
     
    jayshah, Jan 25, 2008 IP
  5. junandya

    junandya Member

    Messages:
    79
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #5
    But Jayshah.....the message which displayed from echo is 'Sent properly', when the script executed at server A just the same as displayed in server B, it should mean the email has been sent, but the email is never received from server A.
     
    junandya, Jan 25, 2008 IP
  6. webexpert

    webexpert Banned

    Messages:
    188
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    your script seems fine.. But it will only work if your server dont need smtp authentication..

    So, i guess, one of your server dont need smtp authentication to send emails thats why script is working there.. however one of your server needs smtp authentication to send emails, thatz why it fails to send email when it cannot see any smtp valid authentication in your script..

    to resolve this issue, try to use this php mailer class;

    http://sourceforge.net/projects/phpmailer/

    hope it will help..

    regards,
     
    webexpert, Jan 25, 2008 IP
  7. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #7
    Extract from http://uk.php.net/manual/en/function.mail.php

     
    jayshah, Jan 25, 2008 IP
  8. webexpert

    webexpert Banned

    Messages:
    188
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    i think, when smtp authentication is required, simple php mail() function cannot know that authentication is required and it always executes without any errors, thats why you are recieving the same mesage that message has been send..

     
    webexpert, Jan 25, 2008 IP
  9. webexpert

    webexpert Banned

    Messages:
    188
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    please check your PM, i uploaded PHPmailer at my server for you, sent the download link on PM. and here is the sample code;

    require("phpmailer/class.phpmailer.php");

    $mail = new PHPMailer();

    $mail->IsSMTP();
    $mail->Host = "xxxxxxxxxxx";
    $mail->SMTPAuth = true;
    $mail->Username = "xxxxx";
    $mail->Password = "xxxxx";

    $mail->From = "xxxxx";
    $mail->FromName = "xxxxxxxx";
    $mail->AddAddress("xxxxxxxxx");


    $mail->WordWrap = 50;
    $mail->IsHTML(true);

    $mail->Subject = "xxxxxxxxxxxx";


    $mail->Body = "xxxxxxx";

    $mail->Send();

    hope it will be helpful..

    regards,
     
    webexpert, Jan 25, 2008 IP