My simply PHP script to send mail is
<?php
ini_set( 'display_errors', 1 );
error_reporting( E_ALL );
$from = "fromaddress@gmail.com";
$to = "toaddress@gmail.com";
$subject = "PHP Mail Test script";
$message = "This is a test to check the PHP Mail functionality";
$headers = "From:" . $from;
mail($to,$subject,$message, $headers);
echo "Test email sent";
?>
When I run this script on any other server it is working fine, but when doing it on my new CentOS 7 machine I always get error in /var/log/maillog
Mar 15 19:08:38 host sendmail[1521]: u2FN8cfK001521: from=root, size=23, class=0, nrcpts=1, msgid=<201603152308.u2FN8cfK001521@host.example.com>, relay=root@localhost
Mar 15 19:08:38 host sendmail[1522]: u2FN8cTc001522: from=<root@host.example.com>, size=328, class=0, nrcpts=1, msgid=<201603152308.u2FN8cfK001521@host.example.com>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Mar 15 19:08:38 host sendmail[1521]: u2FN8cfK001521: to=myemail@gmail.com, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30023, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (u2FN8cTc001522 Message accepted for delivery)
Mar 15 19:08:38 host sendmail[1524]: STARTTLS=client, relay=gmail-smtp-in.l.google.com., version=TLSv1/SSLv3, verify=FAIL, cipher=ECDHE-RSA-AES128-GCM-SHA256, bits=128/128
Mar 15 19:08:39 host sendmail[1524]: u2FN8cTc001522: to=<myemail@gmail.com>, ctladdr=<root@host.example.com> (0/0), delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=120328, relay=gmail-smtp-in.l.google.com. [IPv6:2607:f8b0:400d:c06::1a], dsn=5.0.0, stat=Service unavailable
Mar 15 19:08:39 host sendmail[1524]: u2FN8cTc001522: u2FN8dTc001524: DSN: Service unavailable
Mar 15 19:08:39 host sendmail[1524]: u2FN8dTc001524: to=<root@host.example.com>, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31588, dsn=2.0.0, stat=Sent