1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice
  2. Dear Pleskians, please read this carefully! New attachments and other rules Thank you!
    Dismiss Notice
  3. Dear Pleskians, I really hope that you will share your opinion in this Special topic for chatter about Plesk in the Clouds. Thank you!
    Dismiss Notice

php mail() function not working

Discussion in 'Plesk for Linux - 8.x and Older' started by dave_s_wang, Jan 17, 2006.

  1. dave_s_wang

    dave_s_wang Guest

    0
     
    the php mail() function doesn't work in my installation of plesk. I've looked around on the forum and haven't found any solutions to this issue. What are the first steps to trouble shoot this?

    this is the same php code that is not working:

    <?php
    mail('test111111@hotmail.com', 'test', 'test');
    ?>

    -d
     
  2. jwdick

    jwdick Guest

    0
     
    Upload the following php script as "sendmail.php" to your server. This php script will test your mail() function:


    <!--
    This is a script, written and designed to test the functionality of the
    PHP mail() function on a web hosting account. I offer no warrenty with
    this script. Anyone can use and distribute the script freely.
    -->

    <html>
    <head><title>PHP Mail() test</title></head>
    <body>

    This form will attempt to send a test email. Please enter where this test should be sent to<br><p>
    <form action = "sendmail.php" method = "post" name="sendmail">
    Enter an email address: <input type = "text" name = "to"><br>
    <input type="submit" value="Send" name="submit"><input type="reset" value="Reset" name="reset"><br><p>



    <?php

    if(isset($_POST['to']))
    {
    $host = $_SERVER['HTTP_HOST'];
    $uri = $_SERVER['SCRIPT_URI'];
    $mail_to=$_POST['to'];
    $mail_subject="Test email from $host";
    $mail_body="This is a test email, sent from $uri";
    $header = "Content-type: text/html\n";
    $header .= "From: \"PHP mail() Test Script\"<noreply@$host>\n";


    if(mail($mail_to, $mail_subject, $mail_body,$header))
    {
    print "Email sent successfully!<img src=\"http://dubovik.us/happygir.jpg\">";
    }
    else
    {
    print "Email did not send<img src=\"http://dubovik.us/madgir.jpg\">";
    }
    }
    ?>

    </body>
    </html>
     
  3. dave_s_wang

    dave_s_wang Guest

    0
     
    i get a "Email did not send" using the script. for some reason, the mail() function is returning an error code even tho i am passing in the correct values.

    in my /var/log/httpd/error_log i get :
    sh: /usr/sbin/sendmail: Permission denied

    ls -al on /usr/sbin/sendmail is :
    lrwxrwxrwx 1 root root 23 Oct 11 19:21 /usr/sbin/sendmail -> /var/qmail/bin/sendmail

    ls -al on /var/qmail/bin/sendmail is :
    -r-xr-xr-x 1 root qmail 9756 Aug 24 02:21 /var/qmail/bin/sendmail

    what should the correct permissions be?

    -d
     
  4. jwdick

    jwdick Guest

    0
     
    You have the same permissions set for qmail-inject that I do. But I don't use qmail to send mail in php. I use the sendmail program. In the php.ini file, my sendmail_path is /usr/bin/sendmail -t -i

    Sorry I can't help with qmail
     
  5. dave_s_wang

    dave_s_wang Guest

    0
     
    i changed it back to /usr/sbin/sendmail -t -i and i got the error i wrote above.

    -d
     
  6. jwdick

    jwdick Guest

    0
     
    You have the same permissions set as I do. Strange that it reports a permissions problem in the log file. I will continue to check my notes to see If I can come up with a suggestion for you.
     
  7. jwdick

    jwdick Guest

    0
     
    In your php.ini file, try changing the path to sendmail from the symlink to accessing the sendmail program directly:



    /var/qmail/bin/sendmail



    There maybe a problem with your symlinks
    If I come up with something else, I'll let you know.
     
  8. eric0524

    eric0524 Guest

    0
     
    I have a similar PHP mail issue. I just don't get any emails when php sends them. I used the sendmail.php test and it says, "Email sent successfully!", but, I never got the email in my inbox. I sent it to myself in the "Enter and email address:" but still nothing. Any help would be appreciated. It seems all mail works fine from the server but not on any of the PHP files I have installed.
     
  9. jwdick

    jwdick Guest

    0
     
    After running the sendmail.php test, check your maillogs to see if the email actually comes into your server. There may be an indication in the maillogs as to what is happening.
     
  10. eric0524

    eric0524 Guest

    0
     
    There is nothing in the maillog at all. /var/log/maillog right?
     
  11. jwdick

    jwdick Guest

    0
     
    /var/log/maillog

    It should be /usr/local/psa//var/log/maillog

    Also check your php.ini file in /etc/php.ini :

    In the [Mail function] check sendmail_path Mine is sendmail_path = /usr/sbin/sendmail which is actually a symlink to /var/qmail/bin/sendmail
     
  12. eric0524

    eric0524 Guest

    0
     
    In that maillog I have this:

    [root@host log]# tail maillog
    Feb 2 13:18:30 host qmail: 1138904310.259883 triple bounce: discarding bounce/67873
    Feb 2 13:18:30 host qmail: 1138904310.259915 end msg 67873
    Feb 2 13:18:30 host qmail: 1138904310.396410 delivery 8: failure: Sorry,_I_couldn't_find_any_host_named_host.anodynetherapyllc.com._(#5.1.2)/
    Feb 2 13:18:30 host qmail: 1138904310.396546 status: local 0/10 remote 1/20
    Feb 2 13:18:30 host qmail: 1138904310.396582 triple bounce: discarding bounce/67877
    Feb 2 13:18:30 host qmail: 1138904310.396614 end msg 67877
    Feb 2 13:18:30 host qmail: 1138904310.447426 delivery 9: failure: Sorry,_I_couldn't_find_any_host_named_host.anodynetherapyllc.com._(#5.1.2)/
    Feb 2 13:18:30 host qmail: 1138904310.447566 status: local 0/10 remote 0/20
    Feb 2 13:18:30 host qmail: 1138904310.447599 triple bounce: discarding bounce/67881
    Feb 2 13:18:30 host qmail: 1138904310.447632 end msg 67881
    [root@host log]#
     
  13. jwdick

    jwdick Guest

    0
     
    If that is all that is in your maillogs, then it appears that PHP's mail function does not know the correct path to sendmail or that the permissions for 'sendmail' are not correct.
     
  14. eric0524

    eric0524 Guest

    0
     
    sendmail has a sybolic link to qmail......

    sendmail -> /var/qmail/bin/sendmail

    permissions in /var/qmail/bin sendmail are r-xr-xr-x root qmail
     
  15. jwdick

    jwdick Guest

    0
     
    Have you checked your local and remote queues to make sure the messages are locked in the queue awaiting processing?
     
  16. eric0524

    eric0524 Guest

    0
     
    I modified the me file in qmail and changed it from it's default of host.anodynetheropyllc.com to mail.anodynetherapyllc.com and the sendmail.php test just delivered me an email. Now to test the helpdesk...... Thanks SO much for your help, you got me on the right track. Hope that this solves it all.
     
  17. jwdick

    jwdick Guest

    0
     
    Glad that I could help. I'm sorry that I never even thought about the me file. I'll file this away for next time.

    Good Luck!
     
  18. riquel

    riquel Guest

    0
     
    what was it that you have done??
    which file have you modified?
     
  19. eric0524

    eric0524 Guest

    0
     
    I modified /var/qmail/control/me file and changed the default host.yourdomainname.com to mail.yourdomainname.com then saved it. Restarted qmail via /etc/rc.d/init.d/qmail restart.
     
  20. riquel

    riquel Guest

    0
     
    huh?

    All that my me file contains is the name of my server... which is obviously not the mail URL

    Shall I change the content to "mail.themaindomain.com" ?

    What if I host various domain names? Use the main one?
     
Loading...