0

I moved a PHP-mail-script from an Apache-server to the the root folder of an Nginx-Server (Ubuntu 12.0.4 LTS, MySQL, PHP5-FPM). The form was working perfectly on the Apache-server, however, on the the nginx-server I am getting an ERROR-message, when I try to send mails.

phpinfo() returns the following details regarding the mail settings:

php-fpm                     - active
mail.add_x_header           - On    
mail.force_extra_parameters - no value  
mail.log                    - no value

sendmail_from               - no value  
sendmail_path               - /usr/sbin/sendmail -t -i 

The php.ini states the following:

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = me@example.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path =

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =

; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = On

; The path to a log file that will log all mail() calls. Log entries include
; the full path of the script, line number, To address and headers.
;mail.log =

/var/log/mail.log states the following:

Jan 27 10:11:49 localhost sendmail[22457]: My unqualified host name (localhost) unknown; sleeping for retry
Jan 27 10:12:49 localhost sendmail[22457]: unable to qualify my own domain name (localhost) -- using short name
Jan 27 10:12:50 localhost sendmail[22457]: gethostbyaddr(192.241.186.7) failed: 1
Jan 27 10:12:50 localhost sendmail[22457]: gethostbyaddr(10.128.248.128) failed: 1
Jan 27 10:12:50 localhost sendmail[22457]: alias database /etc/mail/aliases rebuilt by root
Jan 27 10:12:50 localhost sendmail[22457]: /etc/mail/aliases: 4 aliases, longest 10 bytes, 66 bytes total
Jan 27 10:12:50 localhost sm-mta[22516]: My unqualified host name (localhost) unknown; sleeping for retry
Jan 27 10:12:52 localhost sm-msp-queue[22521]: My unqualified host name (localhost) unknown; sleeping for retry
Jan 27 10:13:50 localhost sm-mta[22516]: unable to qualify my own domain name (localhost) -- using short name
Jan 27 10:13:50 localhost sm-mta[22516]: gethostbyaddr(192.241.186.7) failed: 1
Jan 27 10:13:50 localhost sm-mta[22516]: gethostbyaddr(10.128.248.128) failed: 1
Jan 27 10:13:50 localhost sm-mta[22523]: starting daemon (8.14.4): SMTP+queueing@00:10:00
Jan 27 10:13:52 localhost sm-msp-queue[22521]: unable to qualify my own domain name (localhost) -- using short name
Jan 27 10:14:10 localhost sendmail[22542]: My unqualified host name (localhost) unknown; sleeping for retry
Jan 27 10:15:10 localhost sendmail[22542]: unable to qualify my own domain name (localhost) -- using short name
Jan 27 10:15:10 localhost sendmail[22542]: s0RFFAmY022542: from=www-data, size=423, class=0, nrcpts=1, msgid=<201401271515.s0RFFAmY022542@$
Jan 27 10:15:10 localhost sm-mta[22546]: s0RFFAC7022546: from=<www-data@localhost>, size=638, class=0, nrcpts=1, msgid=<201401271515.s0RFF$
Jan 27 10:15:10 localhost sendmail[22542]: s0RFFAmY022542: to=example@outlook.com, ctladdr=www-data (33/33), delay=00:00:00, xdelay=00:00$
Jan 27 10:15:11 localhost sm-mta[22548]: s0RFFAC7022546: to=<example@outlook.com>, ctladdr=<www-data@localhost> (33/33), delay=00:00:01, $enter code here

Does that indicate that PHP Mail() is not correctly set up on my server?

I would appreciate your advice.

  • Troubleshooting 101: read the error messages you get, look at the code they point to. – Álvaro González Jan 27 '14 at 15:17
  • I only get the script-internal message 'Error': `if(mail($address, $e_subject, $msg, $headers)) { // Email has sent successfully, echo a success page. echo "
    "; echo "
    "; echo "

    Email Sent Successfully.

    "; echo "

    Thank you $name, your message has been submitted to us.

    "; echo "
    "; echo "
    "; } else { echo 'ERROR!'; }`
    –  Jan 27 '14 at 15:20

1 Answers1

0
  1. Do you have sendmail installed? If not please have a look at this thread https://stackoverflow.com/a/14886649/610880

  2. Check /var/log/maillog (or whatever your mail log is called) for any errors? (or to at least verify an attempt to mail is made).

  3. Show us any errors from your PHP error log as well.

  4. Also, is your FPM install chroot'd? That may cause such an issue.

  5. Try with phpinfo() from both php (CLI and FPM) and compare the value of the sendmail_path directive.

  6. Also, make sure sendmail is in your PATH and that you haven't altered the following int /usr/local/etc/php/php-fpm.conf ;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com


What are the outputs of hostname and hostname -f ? My guess is that your server doesn't have a fully-qualified domain name.

  • Check we have Fully Qualified Domain Name /bin/hostname

  • it should return something like "ispconfig.example.com"

  • if not, then we assign a hostname (for example ispconfig):

echo ispconfig.example.com > /etc/hostname

/etc/init.d/hostname.sh

vi /etc/hosts

  • and add lines similar but appropriate:

127.0.0.1 localhost.localdomain localhost

192.168.0.100 ispconfig.example.com ispconfig

Community
  • 1
  • 1
Braunson
  • 717
  • 2
  • 12
  • 36
  • `hostname -> Eve ; hostname -f -> localhost;` This is currently a test VPS for development purposes. I haven't transfered a domain yet. '/bin/hostname/' just returns my server-name Eve. –  Jan 27 '14 at 16:28