• Debian 11 is approaching its end-of-life (vendor EOL date - August 31, 2026). Plesk Obsidian 18.0.80 will be the last release to support it.
    If you are running Plesk Obsidian on Debian 11, we recommend you upgrade those servers to Debian 12 using our dist-upgrade tool.
  • We plan to deprecate and remove the support for XML RPC protocol versions earlier than 1.6.9.1 in Plesk Obsidian 18.0.82. We strongly recommend that you update all existing integrations using earlier versions of the XML RPC protocol to comply with the version 1.6.9.1 specification.

Sending email via PHP mail()

Chun..

New Pleskian
Hello,

I'm trying to send emails using the PHP mail() function. Although I'm getting the success message at the end of running the script below, I am not receiving the emails.

Code:
<?php
	$to = '[email protected]';
	$subject = 'Test Email';
	$message = 'Message';
	$mail_sent = mail($to, $subject, $message);
	if ($mail_sent) {
		echo 'success!';
	}
?>

I'm currently using: Parallels Plesk Panel v11.0.9_build110120608.16 os_Ubuntu 10.04
I figured the sendmail program has already been configured when I installed plesk, but I added some additional configuration directives (Power User View -> Websites & Domains -> Website Scripting and Security -> PHP Settings):

http://i.imgur.com/kKa77Yx.png

Code:
[mail function]
SMTP = mail.myserver.com
sendmail_from = [email protected]

Basically I'm trying to send the email using my smtp at mail.myserver.com from the email address [email protected]. Can anyone shed some light on how I can go about fixing this?

Thanks!
 
SMTP = localhost is the way it should be really, and that should not normally be changed. This is very likely why the email is not getting sent. Check your maillog /usr/local/psa/var/log/maillog (or similar) for errors.

But to get what you want, what you actually need is this:

Code:
sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]

Now it is possible that this may not get picked up in the individual domain's php.ini (as created via the PHP Settings section in the panel). Certain PHP settings are global, and can't be overridden. I don't think this is one of them though, so you should be OK.
 
Thanks a lot Faris. I replaced the additional configuration directives bit with the following and restarted the server:

Code:
[mail function]
SMTP = localhost
sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]

Works perfectly now.

SMTP = localhost is the way it should be really, and that should not normally be changed. This is very likely why the email is not getting sent. Check your maillog /usr/local/psa/var/log/maillog (or similar) for errors.

But to get what you want, what you actually need is this:

Code:
sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]

Now it is possible that this may not get picked up in the individual domain's php.ini (as created via the PHP Settings section in the panel). Certain PHP settings are global, and can't be overridden. I don't think this is one of them though, so you should be OK.
 
Back
Top