• 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

Resolved PHP mail() don't work

Office

New Pleskian
Hi there, on my server I had this configuration: - Centos 7, Plesk 17.8.11
I need to send email from server with php. I try a simple script that use PHP mail() function.
The script work well, but the email is not delivered.
May be I need to set up something in Plesk?

Thanks
 
Make sure that Sendmail utility is allowed to use:

Plesk > Tools & Settings > Mail Server Settings
 
Hi IgorG thank for replay. Enable mail management functions in Plesk is checked and Installed Mail server is Qmail.
 

Attachments

  • Schermata 2019-02-26 alle 10.22.20.png
    Schermata 2019-02-26 alle 10.22.20.png
    171.2 KB · Views: 184
How do you know that mail() isn't working? Did you check /var/log/maillog (/var/log/mail.log) to see that the mail is not sent? In that case PHP should show an error mesage in /logs/error_log (/logs/error.log). So either way, did you actually prove that the mail is not being sent?
 
How do you know that mail() isn't working? Did you check /var/log/maillog (/var/log/mail.log) to see that the mail is not sent? In that case PHP should show an error mesage in /logs/error_log (/logs/error.log). So either way, did you actually prove that the mail is not being sent?
I said that php mail function works, the problem is that the email is not delivered. No error in log files
 
"Not delivered" does not mean "not sent". It is crucial to know whether the e-mail is placed into the mail out queue. Try to find it in /var/log/maillog (/var/log/mail.log), because there you can normally see what the mail server is doing with it. You can normally find it by searching for the recipient address, e.g.
# grep "<recipient address here>" /var/log/maillog
and then read the unique processing id (e.g. B1D992A98722F9) and displaying all entries of that id like
# grep "<unique processing id>" /var/log/maillog
 
"Not delivered" does not mean "not sent". It is crucial to know whether the e-mail is placed into the mail out queue. Try to find it in /var/log/maillog (/var/log/mail.log), because there you can normally see what the mail server is doing with it. You can normally find it by searching for the recipient address, e.g.
# grep "<recipient address here>" /var/log/maillog
and then read the unique processing id (e.g. B1D992A98722F9) and displaying all entries of that id like
# grep "<unique processing id>" /var/log/maillog
this is the maillog content

Feb 26 03:54:52 server /var/qmail/bin/relaylock[6544]: /var/qmail/bin/relaylock: mail from <ip>:60725 (not defined)

Feb 26 03:54:52 server smtp_auth[6545]: SMTP connect from unknown [<ip>]
 
If the commands are given correctly, the grep search phrase must be part of the output. In the case shown above it is not, hence the commands were not entered correctly.

For example
# grep 6544 /var/log/maillog
could possibly yield the output shown above. But where is the recipient address in this? This does not seem to be linked to mail sending attempts.
 
If the commands are given correctly, the grep search phrase must be part of the output. In the case shown above it is not, hence the commands were not entered correctly.

For example
# grep 6544 /var/log/maillog
could possibly yield the output shown above. But where is the recipient address in this? This does not seem to be linked to mail sending attempts.
Ok, sorry I understand better now:
Feb 26 12:12:50 server smtp_auth[12521]: No such user 'info@mysite' in mail authorization database

Feb 26 12:12:50 server smtp_auth[12521]: FAILED: info@mysite - password incorrect from (null) [ip]

Feb 26 12:13:38 server qmail: 1551179618.547648 starting delivery 123: msg 189694 to local mysite-info@mysite

Feb 26 12:13:38 server qmail-local-handlers[12569]: to=mysite-info@mysite

Feb 26 12:14:08 server qmail: 1551179648.737256 starting delivery 124: msg 189714 to local mysite-info@mysite

Feb 26 12:14:08 server qmail-local-handlers[12610]: to=mysite-info@mysite

mysite is a regulare web site and ip is the ip of my connection.
 
Do you see more details when doing
# grep 12569 /var/log/maillog
?

It does not look wrong, rather that the mail is being delivered to the local mailbox.
 
So your script is trying to send mail to an e-mail address that is ending on the same domain where the script is sending from, but your mailboxes for that domain are not located on the same server? In that case, the mail will be sent, but it will not leave the local host, because the local host thinks it is responsible for managing the domain, including the mailboxes of the domain. Mails using mail() are being delivered, but not to the external mailbox, but the local mailbox on the sending system.

In this configuration, you cannot use a simple mailing function. Instead, you must use an SMTP mailer and login to an external system (most likely the mail managing system of your domain) to send mail to the externally located mailbox of the domain.
 
Hi,
I am facing an issue of not able to sending mail from my mailing function in php form my specific domain (ex: abc.com), i have another domain ex: def.com on same server but from there the mail is sending succesfully unable to recognize what the issue is?
Can any one please assists.
Thanks in Advance.
 
Have you looked into /var/log/maillog (mail.log on Debian) what it says when you try to send a mail?
 
Back
Top