Post by ReleaseTheGeese » Fri Jun 19, 2020 1:21 am

Dear all,

I'm having an issue with OpenCart's Mail configuration.

We wish to have our emails sent from 'noreply@<domain>.tld' and not the site owner's personal email address. This is to avoid anti-spam filtering our messages, which fail the domain authentication requirements. It would also be generally preferable to keep email addresses separate.

So I set the sendmail parameters to use '-f noreply@<domain>.tld' . Sendmail received the parameter but this doesn't seem to work. Here's an excerpt from the mail log:

Code: Select all

... /usr/sbin/sendmail -t -i -f noreply@<domain>.tld
Also, we still wish for OpenCart to send all contact form requests and notifications to the personal email; using the noreply address as the master email setting is not possible. Besides, as previously mentioned, using a personal email as the sender causes the recipient's email client to flag the message as "failed domain authentication".

I'd appreciate any help and advice.
Regards.

User avatar

Posts

Joined
Thu Jun 18, 2020 10:16 pm

Post by letxobnav » Fri Jun 19, 2020 9:05 am

OC mail class does 2 things, put the -f parameter in the mail header and temporarily override the send_from php setting with the from variable in OC, the rest is up to your server setup.

So you could comment out this line:

Code: Select all

ini_set('sendmail_from', $this->from);
in system/library/mail/mail.php
and make sure you have your sendmail_from setting correct in php.ini
Then all mail send would use that address.

While there you might also want to change this:

Code: Select all

		if ($this->parameter) {
			mail($to, '=?UTF-8?B?' . base64_encode($this->subject) . '?=', $message, $header, $this->parameter);
		} else {
			mail($to, '=?UTF-8?B?' . base64_encode($this->subject) . '?=', $message, $header);
		}

into this:

Code: Select all

		if ($this->parameter) {
			$mail_send = mail($to, '=?UTF-8?B?' . base64_encode($this->subject) . '?=', $message, $header, $this->parameter);
		} else {
			$mail_send = mail($to, '=?UTF-8?B?' . base64_encode($this->subject) . '?=', $message, $header);
		}
		if (!$mail_send) error_log('Error sending mail "'.$this->subject.'" to '.$to);

So you have some indicaton in your log when mail has not left the building.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by paulfeakins » Fri Jun 19, 2020 6:09 pm

ReleaseTheGeese wrote:
Fri Jun 19, 2020 1:21 am
We wish to have our emails sent from 'noreply@<domain>.tld' and not the site owner's personal email address.
Noreply email addresses really annoy me.

You should consider setting up and using an actual email address at the website domain, getting email from a gmail address or similar looks very unprofessional.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by ReleaseTheGeese » Tue Jun 23, 2020 10:35 pm

letxobnav, thanks very much for replying. I made your suggested changes, unfortunately they didn't work here. Insofar as I understand the OC source and sendmail, there isn't any reason that simple edit shouldn't have worked.

Inside php.ini, I set the sendmail_from variable to be our "from" address. It showed correctly in phpinfo() but still wasn't used to send the email.

So, as a fix and a sin against OO programming, I edited `system/library/mail.php` as such:

Code: Select all

	public function setFrom($from) {
#		$this->from = $from;
    	$this->from = 'noreply@<domain>.tld';
	}
And now the emails send with the correct address and are not interned as "spam" due to failing domain authentication. I realise this has damned my soul (pray forgive me gracious devs), but it is unfortunately the only way I could get this to work.

However, this server has been throwing some other frustrating quirks... quirks that didn't appear when I ran OC from my original test server and so I don't think should be blamed on OC. I wouldn't be surprised if this issue is part of another problem server-end.

EDIT: I'm guessing my "fix" might clash with the "Contact Us" form, if we have the user's email as the "From" value. A saner idea might be to set the default value to our noreply in the constructor, then remove where setFrom() is called in the rest of the code when we want the default email.
paulfeakins wrote:
Fri Jun 19, 2020 6:09 pm
Noreply email addresses really annoy me.

You should consider setting up and using an actual email address at the website domain, getting email from a gmail address or similar looks very unprofessional.
I agree personally. However, given the current size of this website and client, it suits their current workflow to have it this way.

We'll have contact events and any notification emails from OC go to the client's personal email address.

Any notification to the customer will be sent from the noreply. That is more to do with avoiding the auth failures, since the emails are sent from the same server as the website. Thereby they won't appear as from the personal email address. We also expect clients to use the contact form or telephone number for queries.

User avatar

Posts

Joined
Thu Jun 18, 2020 10:16 pm
Who is online

Users browsing this forum: Bing [Bot], nonnedelectari and 409 guests