I'm trying to send simply emails via PHP mail() function from a server PLESK, using sendmail (in /usr/sbin/sendmail).
I already read the checklist by John Conde explained here PHP mail function doesn't complete sending of e-mail and my problem is most probably with the provider because my script sends emails to a gmail account, but noone else; the email sent to gmail accounts go into the SPAM folder. I'm trying to send to a name@company.it for example.
Before you ask I already checked my sender IP reputation, verified the reverse DNS result and obtained a score of 9 out 10 on http://mail-tester.com/ [spam checker].
In the php.ini of the domain I put fields as: SMTP, smtp_port, sendmail_from, sendmail_path, auth_password, auth_username. (because I have SSL certificate on the domain, I am using 465 port on a provider smtp server).
This is the snippet of code:
<?php
error_reporting(-1);
ini_set('display_errors', 'On');
ini_set('display_startup_errors', 1);
set_error_handler("var_dump");
//
$replyTo = "website@globalpower.it";
$mailTo = "fcaliari@e-globalservice.it";
//Test sender delle Email
$headers = 'From: '.$replyTo."\r\n".
'Reply-To: '.$replyTo."\r\n" .'X-Mailer: PHP/' . phpversion();
if (mail($mailTo,"Title","Body of the message",$headers)){
echo "Mail ok";
} else {
echo "Error Mail";
}
?>
This is the log of the server under mail directory
Aug 23 10:38:20 webserver check-quota[1905]: Starting the check-quota filter...
Aug 23 10:38:20 webserver journal: plesk sendmail[1904]: handlers_stderr: SKIP
Aug 23 10:38:20 webserver journal: plesk sendmail[1904]: SKIP during call 'check-quota' handler
Aug 23 10:38:20 webserver postfix/pickup[1560]: DAC521A8B: uid=10003 from=<rootgp@globalpower.it>
Aug 23 10:38:20 webserver postfix/cleanup[1910]: DAC521A8B: message-id=<20180823143820.DAC521A8B@webserver.e-globalservice.it>
Aug 23 10:38:20 webserver postfix/qmgr[1561]: DAC521A8B: from=<rootgp@globalpower.it>, size=450, nrcpt=1 (queue active)
Aug 23 10:38:20 webserver postfix-local[1915]: postfix-local: from=rootgp@globalpower.it, to=fcaliari@e-globalservice.it, dirname=/var/qmail/mailnames
Aug 23 10:38:20 webserver postfix-local[1915]: cannot chdir to mailname dir fcaliari: No such file or directory
Aug 23 10:38:20 webserver postfix-local[1915]: Unknown user: fcaliari@e-globalservice.it
Aug 23 10:38:20 webserver postfix/pipe[1914]: DAC521A8B: to=<fcaliari@e-globalservice.it>, relay=plesk_virtual, delay=0.05, delays=0.03/0.01/0/0.01, dsn=2.0.0, status=sent (delivered via plesk_virtual service)
Aug 23 10:38:20 webserver postfix/qmgr[1561]: DAC521A8B: removed
In the logs appears this email rootgp@gloablpower.it which I never used in the php.ini file or in the script
Any help appreciate!