php mail() not working with Postfix, Dovecot, MySQL and SquirrelMail
Can anyone help me out, I've followed the Postfix, Dovecot, MySQL and SquirrelMail guide on Ubuntu 16.04 and I can send and recieve emails using the domain/squirrelmail interface but I can't send it through a PHP mail() function.
I have set php.ini sendmail_path = "/usr/sbin/sendmail -t -i" . Getting really lost with where I am going wrong. The format of the PHP form is correct as far as I know. Any ideas? any other info I should post up here?
Thanks in advance!
5 Replies
It's possible, though unlikely, that /usr/sbin/sendmail is the problem; you can test it as follows:
$ /usr/sbin/sendmail -t -i
> From: me@mydomain.com
> To: me@someexternaldomain.com
> Subject: testing
>
> This is a test.
> (Ctrl-D)
You should then receive this message at your
With regards to the sendmail from CLI, it sent the mail successfully! Leads me to think somehow php isn't being connected. I have attached the php.ini from /etc/php/7.0/apache2/ in case it helps to find the error. I've tried the sendmail_path with quotes without quotes to no avail.
[Pdo_mysql]
; If mysqlnd is used: Number of cache slots for the internal result set cache
; http://php.net/pdo_mysql.cache_size
pdo_mysql.cache_size = 2000
; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
; http://php.net/pdo_mysql.default-socket
pdo_mysql.default_socket=
[Phar]
; http://php.net/phar.readonly
;phar.readonly = On
; http://php.net/phar.require-hash
;phar.require_hash = On
;phar.cache_list =
[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= "/usr/sbin/sendmail -t -i"
; 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().
;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
; Log mail to syslog (Event Log on Windows).
;mail.log = syslog
[SQL]
; http://php.net/sql.safe-mode
sql.safe_mode = Off
the defaults
If I run the command tail -f /var/log/syslog , I get this in the logs.
root@hydrogen:~# tail -f /var/log/syslog
May 22 10:29:54 hydrogen systemd[1]: Starting LSB: Apache2 web server...
May 22 10:29:54 hydrogen apache2[3199]: * Starting Apache httpd web server apache2
May 22 10:29:56 hydrogen apache2[3199]: *
May 22 10:29:56 hydrogen systemd[1]: Started LSB: Apache2 web server.
May 22 10:30:28 hydrogen postfix/sendmail[3263]: fatal: open /etc/postfix/main.cf: Permission denied
May 22 10:30:31 hydrogen postfix/sendmail[3265]: fatal: open /etc/postfix/main.cf: Permission denied
May 22 10:30:33 hydrogen postfix/sendmail[3267]: fatal: open /etc/postfix/main.cf: Permission denied
May 22 10:30:34 hydrogen postfix/sendmail[3269]: fatal: open /etc/postfix/main.cf: Permission denied
May 22 10:30:35 hydrogen postfix/sendmail[3271]: fatal: open /etc/postfix/main.cf: Permission denied
May 22 10:30:37 hydrogen postfix/sendmail[3273]: fatal: open /etc/postfix/main.cf: Permission denied
Do you know which command I can enter to give permission to Apache/fix this issue?
Thanks
Thanks for all the help and support Vance