Laravel Framework version 5.3.31, Swiftmailer v5.4.12 running on a Ubuntu VPS on nginx.
Laravel app is sending mail using SMTP to a shared hosting email server. Worked for two years plus. Hosting company migrated to new servers this week and mail delivery was broken.
Mail being sent is to other domain (e.g. gmail.com) cc to our domain (ourdomain.ca).
Server was delivering cc mail addressed to our domain but discarding mail to any other domain.
Drupal instance on same VPS server sending mail using same SMTP server delivers mail to our domain and all other domains.
Inspection of email from Laravel not delivered to other domain but delivered to our domain shows HELO=[127.0.0.1] which (I think) the SMTP server is discarding because it says "I'm 127.0.0.1, you can't be 127.0.0.1, this is SPAM, off to /dev/null". Hosting company tech support is useless but they inadvertently sent an exim log which shows this. Mail from Drupal shows HELO=ourdomain.ca.
So I start digging into the Laravel site (which has been unchanged in mail sending functionality other than composer update).
I look at swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php. It has a protected $_domain variable defaulted to '[127.0.0.1]' and a function setLocalDomain($domain) which is supposed to be called to set the domain.
The function is never being called that I can find, so the default is being used, and that's why my mail isn't being delivered.
I have changed the default in AbstractSmtpTransport.php but that of course isn't a good long term solution as it will be regularly overwritten.
I need some clues though as to where I can modify in my code to call the setLocalDomain function to get the right domain in the HELO. I'm using the Mail facade and Mailables.
// create mail from Mailable
$email = new LicencePurchased($member, $licence, $sale_type, $request->process_type);
// queue mail now
Mail::to($member->email)->cc('[email protected]')->bcc('[email protected]')->queue($email);
TIA for any help.