• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

mail() in PHP doesn't work with Qmail

mooiesite

Basic Pleskian
Mail(); in PHP doesn't do anything.

Using mail in a shell isn't a problem, so sendmail is working!

PHP doesn't give me any errors (error reporting: ALL)

PHP.ini contains the right path to sendmail. I tried all the options like:

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = /var/qmail/bin/sendmail

or
sendmail_path= /var/qmail/bin/qmail-inject

In phpinfo() all the paths are right, but it doesn't mail anything (neither internally or with external mailaddresses)

I check the rights, even chmod 777 on sendmail or qmail-inject doesn't do a thing.

Even this doesn't work:
as root:
# /usr/bin/php -f test.php

and test.php is this:
<?
ini_set('error_reporting', E_ALL);
$mailHeaders = "From: domain.nl <[email protected]>";
$mailSubject = "Test";
$mailBody = "Test body";
$mailTo = "[email protected]";
mail($mailTo, $mailSubject, $mailBody, $mailHeaders);
?>

Is there anyone who knows how to fix this or knows a work-around?
 
I'm having a similar problem. Web forms using the mail() function are no longer sending emails to certain domains. gmail, hotmail, etc. will receive the email, but not other domains.

I say no longer send emails because I moved from a shared hosting server to a VPS. They were working previously. Any more info on this?
 
Yea anyone?

Even worse, php webpages seem to execute. Using the php CLI in interactive mode it will seg fault right after the mail command.
 
This probably isn't the solution but....

In the past when php segfaulted on me it was usually down to having an older version of Zend optimizer installed.

So as a first step you might want to try installing the very latest zend (and ioncube if necessary) and make sure that any older Zend/Ioncube entries are removed from php.ini.

Faris.
 
If you have access to your DNS records, some of you may want to check and make sure your mail's MX record is properly setup if your mail is being hosted elsewhere, this solved the issue for me but we just have a really odd server setup. I hate it -_-
 
Disabling selinux solved it for me (that is, the interpreter in apache, the php cli still segfaults if i call mail() even with selinux entirely disabled).
 
That's extremely worrying. selinux bit me on the behind with another problem not so long ago. It is so annoying. It has so many benefits but too many problems.

Faris.
 
Hello,


I do not believe that you can use mail() with sendmail path :

/var/qmail/bin/sendmail

use simply :

/usr/sbin/sendmail


As for hotmail and gmail they are very strict in filtering their email. Try to use spf's maybe that will help.
 
Why would you believe that and why wouldn't it be possible?

It works... :) In fact, the qmail sendmail binary is recommended on many forums if you use qmail. Normally /usr/sbin/sendmail should be a symlink to it, but appearantly fedora or plesk (whatever installed qmail) screwed up creating the symlink. As I don't want an update to qmail or whatever to break the link again I just pointed it to the binary.
 
Thanks for the re...

At the risk of sounding stupid, can anyone explain why ppl keep proposing solutions on something that's already solved? :D Cuz I can't figure it out...
 
Well, sometimes (like my times), we don't have access to use that resolution, and frankly: my hosting guy isn't as bright as i'd like him to be.
 
same problem

same problem, mail won't send off the box with a php mail(), old server worked perfect, new server well you all know.

I tried the selinux permissive etc... no effect at all.

seems there should be a difinative solution here as everyone is having the same exact issue? I did have plesk 7 and now i have plesk 8?

this is horrible anyone have THE answer?
 
solution

Hello,
You should reinstall Qmail package from plesk, please looking for inside Plesk folders after download the correct version.

Why it occur?

Because, Plesk first compile PHP and not Qmail then is neccesary reinstall Qmail with --force for PHP works fine with mail()...

Regards.
 
My solution

Ok I figured this out last night

http://kb.swsoft.com/article_22_144_en.html

1) 127.0.0.0/8 network is added to white list in Plesk CP (Server-> Mail -> White List)

2) Make sure that /usr/sbin/sendmail and /usr/lib/sendmail are a
symbolic links to Plesk sendmail binary (/var/qmail/bin/sendmail).

and then adjusted my php to

1. Log in as ROOT to your server and do the following:
2. Issue these root commands:
a. cd /usr/sbin (this changes to the directory)
b. readlink sendmail (this displays where the symbolic link points.)
> In my case it was pointing to: /etc/alternatives/mta/sendmail
> That is good.
c. cd /usr/lib (change to next directory)
d. readlink sendmail (again, show where it points).
> In my case, nothing displayed because the file/link did not exist.
> I then ran the command to create a symbolic link
> ln -s /etc/alternatives/mta sendmail
> Now when I use readlink sendmail it gives me this symbolic link
3. That was it… My sendmail from within PHP now worked.

here is the thread.

http://forum.swsoft.com/showthread.php?s=&threadid=44434&highlight=php+mail
 
Back
Top