Results 1 to 12 of 12
  1. #1
    Join Date
    Feb 2002
    Location
    New York
    Posts
    791

    php mail() not working on new server

    Hello all,

    So I just setup a ubuntu LAMP server. Now I have reports that php mail() is not working??

    when I look at my phpinfo() I see
    sendmail_from no value no value
    sendmail_path /usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i

    yet I have even tested it out and see that my script says it works but the mail never reaches my inbox?? Suggestions on what I might have missed during the setup or maybe there is a config I need to change in my servers php.ini file ??

    here is my php script
    PHP Code:
    <?php
    $to 
    "[email protected]";
    $header "FROM: [email protected]";
    $subject "Hi!";
    $body "Hi,\n\nHow are you?";
    if (
    mail($to$subject$body$header)) {
      echo(
    "<p>Message successfully sent!</p>");
     } else {
      echo(
    "<p>Message delivery failed...</p>");
     }
    ?>
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    just a programmer

  2. #2
    Join Date
    Jul 2009
    Posts
    178
    pear install mail

    Use this command

  3. #3
    please paste the error from the logs here; is there a problem in sending emails using webmail or email client ?
    Windows VPS | Linux Hybrid Server | 99.9% Uptime
    http://www.odishahosting.com ( USA DC)
    http://www.odishahosting.in ( INDIA DC)

  4. #4
    Join Date
    Apr 2002
    Posts
    930
    First, make sure that /usr/sbin/sendmail really exists on your server.

    If it does, you will need to tail the mail logs while attempting to execute this PHP script. See what the mail logs say about this.

  5. #5
    Join Date
    Feb 2002
    Location
    New York
    Posts
    791

    ...

    Hello

    eth10 I have PEAR mail installed although it is not working and I really am just looking to get the php mail() function to work. Not SMTP based email.

    Also I dont have cpanel or any other panel installed Its just a basic Ubuntu LAMP install which will mostly be used by a client who is a developing a large scale PHP App.

    I am not sure what log file to look at I have a var/log/mail.log but its empty and I dont see any php related log's??
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    just a programmer

  6. #6
    Join Date
    Apr 2002
    Posts
    930
    If sendmail is your MTA then I believe /var/log/mail.log will be the log to look at.

    Is sendmail running?

    /etc/init.d/sendmail status

    to restart it:

    /etc/init.d/sendmail restart

    Are you able to send out e-mail from the server bypassing PHP?

  7. #7
    Join Date
    Feb 2002
    Location
    New York
    Posts
    791
    Yes Sendmail is running I get

    MSP: is run via cron (20m)
    MTA: 6895 /usr/sbin/sendmail-mta -Am -L sm-mta -bd -q10m
    UID PID PPID C STIME TTY TIME CMD
    root 6895 1 0 12:57 ? 00:00:00 sendmail:
    MTA: accepting connections
    Daemon Status: (process 6895) Accepting connections

    Current number of children: 0
    QueueDir free disk space (in blocks): 14553136
    Load average: 0
    Child Process 6945 Status: console socket child

    QUE: Same as MTA
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    just a programmer

  8. #8
    Join Date
    Apr 2002
    Posts
    930
    Try sending a message out directly through sendmail.

    Create a test file, doesn't really matter what you name it, but I'll call it test.txt for reference purposes. In that file add the lines:

    Code:
    From: [email protected]
    To: [email protected]
    Subject: Test Message
    
    Test Message
    save that file and then from the command-line type:

    /usr/sbin/sendmail -t -i < test.txt

    You should receive a test message at [email protected] and your mail.log file should have entries.

  9. #9
    Join Date
    Mar 2009
    Location
    Gods Own Country
    Posts
    681
    Now I have reports that php mail() is not working??
    what does you apache error log say?

  10. #10
    Join Date
    Feb 2002
    Location
    New York
    Posts
    791

    ...

    well my var/log/apache2/error.log has nothing about email in it just some missing image errors
    and I dont see any error log just called apache2.log ??

    I only see access.log and error.log in the apache2 log folder
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    just a programmer

  11. #11
    Join Date
    Mar 2009
    Location
    Gods Own Country
    Posts
    681
    well my var/log/apache2/error.log has nothing about email in it just some missing image errors
    and I dont see any error log just called apache2.log ??

    I only see access.log and error.log in the apache2 log folder
    When you run the mail() in php file, what does your mail log say?

  12. #12
    Join Date
    Feb 2002
    Location
    New York
    Posts
    791

    ..

    mail.info log says
    PHP Code:

    Sep  3 15
    :01:27 hostedsessions sendmail[8546]: n83J1Rg5008546from=www-datasize=86, class=0nrcpts=1msgid=<200909031901.n83J1Rg5008546@hostedsessions.com>, relay=www-data@$
    Sep  3 15:01:27 hostedsessions sm-mta[8547]: n83J1RP7008547from=<www-data@hostedsessions.com>, size=329, class=0nrcpts=1msgid=<200909031901.n83J1Rg5008546@hostedses$
    Sep  3 15:01:27 hostedsessions sendmail[8546]: n83J1Rg5008546to=jreis@hostedsessions.comctladdr=www-data (33/33), delay=00:00:00xdelay=00:00:00mailer=relaypri=30086relay=[127$
    Sep  3 15:01:27 hostedsessions sm-mta[8549]: n83J1RP7008547to=<jreis@hostedsessions.com>, ctladdr=<www-data@hostedsessions.com> (33/33), delay=00:00:00xdelay=00:00:00mailer=e$
    Sep  3 15:01:27 hostedsessions sm-mta[8549]: n83J1RP7008547n83J1RP7008549DSNService unavailable
    Sep  3 15
    :01:27 hostedsessions sm-mta[8549]: n83J1RP7008549to=<www-data@hostedsessions.com>, delay=00:00:00xdelay=00:00:00mailer=localpri=30000dsn=2.0.0stat=Sent 
    My mail.log file says the same as above mail.warn log is empty and mail.err is empty as well

    I also even tried setting up and using pear Mail and get this error
    Warning: Mail_smtp::include_once(Net/SMTP.php) [mail-smtp.include-once]: failed to open stream: No such file or directory in /var/www/PEAR/Mail/smtp.php on line 311

    Warning: Mail_smtp::include_once() [function.include]: Failed opening 'Net/SMTP.php' for inclusion (include_path='.:/var/www/PEAR/') in /var/www/PEAR/Mail/smtp.php on line 311

    Fatal error: Class 'Net_SMTP' not found in /var/www/PEAR/Mail/smtp.php on line 312

    yes I have a REAP folder and a Mail folder in it and I see there is a smtp.php file in the Mail folder. with the correct upper and lowercase letters
    Last edited by mjfroggy; 09-03-2009 at 03:13 PM. Reason: more info
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    just a programmer

Similar Threads

  1. mail server for a domain not working
    By nbento in forum Hosting Security and Technology
    Replies: 0
    Last Post: 05-30-2006, 09:49 AM
  2. Mail server not working :(
    By cyruski in forum Hosting Security and Technology
    Replies: 7
    Last Post: 04-24-2006, 07:53 AM
  3. New Server Root mail not working
    By vantasticman7 in forum Hosting Security and Technology
    Replies: 4
    Last Post: 01-13-2006, 08:39 AM
  4. mail-server is not working
    By mithilesh in forum Hosting Security and Technology
    Replies: 6
    Last Post: 03-26-2003, 08:16 PM
  5. POP3 /IMAP Mail Server NOT WORKING **PLEASE HELP!!!**
    By LCHwebHost in forum Hosting Security and Technology
    Replies: 1
    Last Post: 11-13-2002, 06:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •