Ubuntu 20.04 sendmail PHP 7.4 SPF DKIM1 DMARC1 all set correctly
trying this:
<?php
$to = '[email protected]';
$subject = 'some subject testing object';
$message = 'hello, this is un message';
$headers = 'From: "Something here" <[email protected]>' . "\r\n" .
'Reply-To: "Reply to" <[email protected]>' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
var_dump(
mail($to, $subject, $message, $headers)
);
?>
the output of this is true, obviously and try to see in the logs what happened. This worked before in ubuntu 16.04. After upgrade I have to setup mail server again in the VPS.
Aug 30 13:59:52 vps229XXX sendmail[678555]: 27UDxqF5678555: from=www-data, size=287, class=0, nrcpts=1, msgid=<[email protected]>, relay=www-data@localhost
Aug 30 13:59:52 vps229XXX sm-mta[678556]: 27UDxqa4678556: from=<[email protected]>, size=520, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Aug 30 13:59:52 vps229XXX sendmail[678555]: 27UDxqF5678555: [email protected], ctladdr=www-data (33/33), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30287, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (27UDxqa4678556 Message accepted for delivery)
Aug 30 13:59:53 vps229XXX sm-mta[678558]: STARTTLS=client, relay=gmail-smtp-in.l.google.com., version=TLSv1.3, verify=FAIL, cipher=TLS_AES_256_GCM_SHA384, bits=256/256
Aug 30 13:59:53 vps229XXX sm-mta[678558]: 27UDxqa4678556: to=<[email protected]>, ctladdr=<[email protected]> (33/33), delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=120520, relay=gmail-smtp-in.l.google.com. [172.253.122.27], dsn=5.0.0, stat=Service unavailable
Aug 30 13:59:53 vps229XXX sm-mta[678558]: 27UDxqa4678556: 27UDxra4678558: DSN: Service unavailable
Aug 30 13:59:53 vps229XXX sm-mta[678558]: 27UDxra4678558: to=<[email protected]>, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30000, dsn=2.0.0, stat=Sent
in the logs we've seen this. I have checked in google and the trouble seems to be in SPF1 but i've allowed the VPS domain also and doesn't work.
after seeing some options in mail() php manual, i've seen there is a way to set manually the domain sender. Is not the best way but is a patch is working now for gmail:
mail($to, $subject, $message, $headers, " [email protected]")
the unspace between the mail and "-f" it's intended. AFter this, GMail is not returnend my mails. The mails get into spam, that's another fight to make, but now they're turned into.