Post by MadMcJack » Tue Jul 06, 2021 7:52 pm

I am using Opencart 3.0.3.7 and when emails are being sent to customers using spamassassin they are flagged as follows:

Symbol: SUBJ_EXCESS_BASE64(1.50)
Symbol: FROM_EXCESS_BASE64(1.50)
Symbol: MIME_BASE64_TEXT_BOGUS(1.00)
Symbol: MIME_BASE64_TEXT(0.10)
Symbol: CTYPE_MIXED_BOGUS(1.00)
Symbol: R_PARTS_DIFFER(0.37)
Symbol: MISSING_MID(2.50)

We are doing nothing fancy and these scores seem to indicate basic mail headers.

The MISSING_MID(2.50) indicates a missing Message-ID header for instance.
https://stackoverflow.com/questions/144 ... ent-by-php

There also seem to be problems with the base64_encoded parts in To, From, Reply To and Subject?

Newbie

Posts

Joined
Fri Aug 07, 2020 6:41 pm

Post by ADD Creative » Tue Jul 06, 2021 8:33 pm

Your mail server should be adding the Message-ID if it's not there. You might want to check its settings. Base64 scores also look high.

I believe this has been reported before.
https://github.com/opencart/opencart/pull/7440

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by MadMcJack » Tue Jul 06, 2021 9:50 pm

Thanks. It looks like the exact issue I was having.

I am not in control of the mail server so I have asked them to check why the message-id is not being set.

As for the utf8_encode parts... Spamassassin seems to think that is indicative of somebody trying to be spammer.

Not sure if that is OpenCart's problem (don't think so).

Newbie

Posts

Joined
Fri Aug 07, 2020 6:41 pm

Post by ADD Creative » Wed Jul 07, 2021 2:17 am

I think it is an OpenCart problem. If spam filters put such a large weight to it being spam then unnecessarily Base64 encoding should be avoided.

The same with the missing Message-ID header. If spam filters give it such a large weight and the addition of a message-id field when none appears is only something a MTA MAY add. Then it would be best for OpenCart to set this.

Have you tried using the "Mail" Mail Engine to see if that adds the Message-ID header?

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by paulfeakins » Wed Jul 07, 2021 4:39 pm

ADD Creative wrote:
Wed Jul 07, 2021 2:17 am
I think it is an OpenCart problem. If spam filters put such a large weight to it being spam then unnecessarily Base64 encoding should be avoided.

The same with the missing Message-ID header. If spam filters give it such a large weight and the addition of a message-id field when none appears is only something a MTA MAY add. Then it would be best for OpenCart to set this.

Have you tried using the "Mail" Mail Engine to see if that adds the Message-ID header?
Could be that OpenCart needs to optimise the emails that are sent as it seems that email delivery systems are getting stricter and stricter these days.

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 JNeuhoff » Wed Jul 07, 2021 6:55 pm

Could be that OpenCart needs to optimise the emails that are sent as it seems that email delivery systems are getting stricter and stricter these days.
Also, mails using outlook.com, hotmail.com, live.com, or msn.com tend to be more likely to be treated as spam. It's better to use domain-name specific email accounts. Besides, the MS-based services frequently violate the GDPR rules, by automatically sniffing out the actual mail contents for purposes other than a mail delivery.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member
Online

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by EvolveWebHosting » Wed Jul 07, 2021 8:43 pm

Have you tried sending via SMTP and also make sure you have DKIM and SPF Records setup.

Instructions for setting up SPF and DKIM in cPanel (it's simple)
https://core.evolvewebhost.com/knowledg ... entication

Opencart Hosting Plans, Domain Registration, Microsoft and Google Email and More
Visit our website for great deals and most importantly, fast and friendly support - www.evolvewebhost.com


User avatar
Active Member

Posts

Joined
Fri Mar 27, 2015 11:13 pm
Location - Denver, Colorado, USA

Post by sjgarth » Mon Jul 12, 2021 1:28 am

I send by SMTP, I have DKIM and SPF set up correctly and the problem is OPENCART.
It encodes all emails as base54 and the anti spam measures used by my (and many other) service providers does not allow unnecessary base64 encoding.
This is causing a big problem and OPENCART - not the users or the service providers - need to sort this out.
At the moment I have a shop which doesn't contact the customers.

New member

Posts

Joined
Mon Mar 19, 2018 12:22 am

Post by sjgarth » Tue Jul 13, 2021 1:01 am

As I posted previously, I use the SMTP option for mail, and have DKIM and SPF setup. As a stop gap to prevent base64 encoding I modified the cart2\system\library\mail\smtp.php file to prevent the encoding.
My service provider was stopping unnecessary base64 encoding as an anti spam measure, but recent emails have not been stopped, therefore I think it is a suitable stop gap until Open Cart fix the issue.
I am not an expert by any means, and I do not know if this will cause problems, however testing has shown that emails continue to be sent without any obvious issues.
My smtp.php file is now (all old code commented out) ;

Code: Select all

<?php
namespace Mail;
class Smtp {
	public $smtp_hostname;
	public $smtp_username;
	public $smtp_password;
	public $smtp_port = 25;
	public $smtp_timeout = 5;
	public $verp = false;

	public function send() {
		if (is_array($this->to)) {
			$to = implode(',', $this->to);
		} else {
			$to = $this->to;
		}

		$boundary = '----=_NextPart_' . md5(time());

		$header  = 'MIME-Version: 1.0' . PHP_EOL;
		$header .= 'To: <' . $to . '>' . PHP_EOL;
		/*$header .= 'Subject: =?UTF-8?B?' . base64_encode($this->subject) . '?=' . PHP_EOL;*/
               /*NEW*/ $header .= 'Subject: ' . $this->subject . ' <' . PHP_EOL;
		$header .= 'Date: ' . date('D, d M Y H:i:s O') . PHP_EOL;
		/*$header .= 'From: =?UTF-8?B?' . base64_encode($this->sender) . '?= <' . $this->from . '>' . PHP_EOL;*/
               /*NEW*/ $header .= 'From: ' . $this->sender . ' <' . $this->from . '>' . PHP_EOL;

		if (!$this->reply_to) {
			/*$header .= 'Reply-To: =?UTF-8?B?' . base64_encode($this->sender) . '?= <' . $this->from . '>' . PHP_EOL;*/
           /*NEW*/ $header .= 'Reply-To: ' . $this->sender . ' <' . $this->from . '>' . PHP_EOL;
		} else {
			/*$header .= 'Reply-To: =?UTF-8?B?' . base64_encode($this->reply_to) . ' ' . $this->reply_to . '>' . PHP_EOL;*/
           /*NEW*/ $header .= 'Reply-To: ' . $this->reply_to . ' <' . $this->reply_to . '>' . PHP_EOL;
		}

		$header .= 'Return-Path: ' . $this->from . PHP_EOL;
		$header .= 'X-Mailer: PHP/' . phpversion() . PHP_EOL;
		$header .= 'Content-Type: multipart/mixed; boundary="' . $boundary . '"' . PHP_EOL . PHP_EOL;

		if (!$this->html) {
			$message  = '--' . $boundary . PHP_EOL;
			$message .= 'Content-Type: text/plain; charset="utf-8"' . PHP_EOL;
			$message .= 'Content-Transfer-Encoding: 8bit' . PHP_EOL . PHP_EOL;
			$message .= $this->text . PHP_EOL;

	EVERYTHING ELSE AS ORIGINAL
	

New member

Posts

Joined
Mon Mar 19, 2018 12:22 am

Post by ADD Creative » Tue Jul 13, 2021 6:02 am

There is an example of one way to only encode if necessary (requiring mbstring) here. https://github.com/opencart/opencart/pull/7440/files

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by by mona » Tue Jul 13, 2021 5:15 pm

you could just do this:

add a private function to the class system/library/mail/smtp.php

Code: Select all

// return base64 encoded if needed ($item not ASCII)
private function mailb64_if_required ($item) {
	return (!mb_check_encoding($item, 'ASCII') ? '=?UTF-8?B?' . base64_encode($item) . '?=' : $item);
}
then change in that same file the calls of:

Code: Select all

$header .= 'Subject: =?UTF-8?B?' . base64_encode($this->subject) . '?=' . PHP_EOL;
to

Code: Select all

$header .= 'Subject: ' . $this->mailb64_if_required($this->subject) . PHP_EOL;

Code: Select all

$header .= 'From: =?UTF-8?B?' . base64_encode($this->sender) . '?= <' . $this->from . '>' . PHP_EOL;
to

Code: Select all

$header .= 'From: ' . $this->mailb64_if_required($this->sender) . ' <' . $this->from . '>' . PHP_EOL;

Code: Select all

$header .= 'Reply-To: =?UTF-8?B?' . base64_encode($this->sender) . '?= <' . $this->from . '>' . PHP_EOL;
to

Code: Select all

$header .= 'Reply-To: ' . $this->mailb64_if_required($this->sender) . ' <' . $this->from . '>' . PHP_EOL;

Code: Select all

$header .= 'Reply-To: =?UTF-8?B?' . base64_encode($this->sender) . '?= <' . $this->reply_to . '>' . PHP_EOL;
to

Code: Select all

$header .= 'Reply-To: ' . $this->mailb64_if_required($this->sender) . ' <' . $this->reply_to . '>' . PHP_EOL;

So you do not have to constantly do:

Code: Select all

if (mb_check_encoding($this->xxxxxx, 'ASCII')) {
} else {
}
keeps it clean.

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by sjgarth » Thu Mar 03, 2022 12:07 am

by mona wrote:
Tue Jul 13, 2021 5:15 pm
you could just do this:

add a private function to the class system/library/mail/smtp.php
...
A bit late I know, but i have just used this solution after updating the software.
So far it appears to work, I hope it continues.
Thanks.

New member

Posts

Joined
Mon Mar 19, 2018 12:22 am

Post by rufus.d » Sat Jan 27, 2024 7:47 pm

This works like a charm to resolve the missing message-id header issues in OC 3.0.3.9 ;D
by mona wrote:
Tue Jul 13, 2021 5:15 pm
you could just do this:

add a private function to the class system/library/mail/smtp.php

Code: Select all

// return base64 encoded if needed ($item not ASCII)
private function mailb64_if_required ($item) {
	return (!mb_check_encoding($item, 'ASCII') ? '=?UTF-8?B?' . base64_encode($item) . '?=' : $item);
}
then change in that same file the calls of:

Code: Select all

$header .= 'Subject: =?UTF-8?B?' . base64_encode($this->subject) . '?=' . PHP_EOL;
to

Code: Select all

$header .= 'Subject: ' . $this->mailb64_if_required($this->subject) . PHP_EOL;

Code: Select all

$header .= 'From: =?UTF-8?B?' . base64_encode($this->sender) . '?= <' . $this->from . '>' . PHP_EOL;
to

Code: Select all

$header .= 'From: ' . $this->mailb64_if_required($this->sender) . ' <' . $this->from . '>' . PHP_EOL;

Code: Select all

$header .= 'Reply-To: =?UTF-8?B?' . base64_encode($this->sender) . '?= <' . $this->from . '>' . PHP_EOL;
to

Code: Select all

$header .= 'Reply-To: ' . $this->mailb64_if_required($this->sender) . ' <' . $this->from . '>' . PHP_EOL;

Code: Select all

$header .= 'Reply-To: =?UTF-8?B?' . base64_encode($this->sender) . '?= <' . $this->reply_to . '>' . PHP_EOL;
to

Code: Select all

$header .= 'Reply-To: ' . $this->mailb64_if_required($this->sender) . ' <' . $this->reply_to . '>' . PHP_EOL;

So you do not have to constantly do:

Code: Select all

if (mb_check_encoding($this->xxxxxx, 'ASCII')) {
} else {
}
keeps it clean.

Newbie

Posts

Joined
Sat Jan 27, 2024 4:02 pm

Post by rufus.d » Sat Jan 27, 2024 10:33 pm

Is there any similar solution for Marketing -> Mails (To send emails to newsletter subscribers). The below modification fixed the issue for all emails, except the one under the marketing. When sent, it's sending without a message-id header and marks as SPAM, which doesn't even reach the user.

Any help would be really appreciated.

Newbie

Posts

Joined
Sat Jan 27, 2024 4:02 pm

Post by ADD Creative » Sat Jan 27, 2024 10:59 pm

rufus.d wrote:
Sat Jan 27, 2024 10:33 pm
Is there any similar solution for Marketing -> Mails (To send emails to newsletter subscribers). The below modification fixed the issue for all emails, except the one under the marketing. When sent, it's sending without a message-id header and marks as SPAM, which doesn't even reach the user.

Any help would be really appreciated.
That code doesn't add a message-id header. It probably just lowers the spam score. Any decent host should add the message-id header if it's not there. Maybe ask you host about it.

I did link to someone else's change that did add a message-id header.
viewtopic.php?p=866184#p824826

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by paulfeakins » Mon Jan 29, 2024 7:44 pm

rufus.d wrote:
Sat Jan 27, 2024 10:33 pm
Is there any similar solution for Marketing -> Mails (To send emails to newsletter subscribers).
I would recommend sending from MailChimp using Clear Thinking's excellent extension.

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 mandom » Fri Apr 05, 2024 4:01 pm

by mona wrote:
Tue Jul 13, 2021 5:15 pm
you could just do this:

add a private function to the class system/library/mail/smtp.php

Code: Select all

// return base64 encoded if needed ($item not ASCII)
private function mailb64_if_required ($item) {
	return (!mb_check_encoding($item, 'ASCII') ? '=?UTF-8?B?' . base64_encode($item) . '?=' : $item);
}
then change in that same file the calls of:

Code: Select all

$header .= 'Subject: =?UTF-8?B?' . base64_encode($this->subject) . '?=' . PHP_EOL;
to

Code: Select all

$header .= 'Subject: ' . $this->mailb64_if_required($this->subject) . PHP_EOL;

Code: Select all

$header .= 'From: =?UTF-8?B?' . base64_encode($this->sender) . '?= <' . $this->from . '>' . PHP_EOL;
to

Code: Select all

$header .= 'From: ' . $this->mailb64_if_required($this->sender) . ' <' . $this->from . '>' . PHP_EOL;

Code: Select all

$header .= 'Reply-To: =?UTF-8?B?' . base64_encode($this->sender) . '?= <' . $this->from . '>' . PHP_EOL;
to

Code: Select all

$header .= 'Reply-To: ' . $this->mailb64_if_required($this->sender) . ' <' . $this->from . '>' . PHP_EOL;

Code: Select all

$header .= 'Reply-To: =?UTF-8?B?' . base64_encode($this->sender) . '?= <' . $this->reply_to . '>' . PHP_EOL;
to

Code: Select all

$header .= 'Reply-To: ' . $this->mailb64_if_required($this->sender) . ' <' . $this->reply_to . '>' . PHP_EOL;

So you do not have to constantly do:

Code: Select all

if (mb_check_encoding($this->xxxxxx, 'ASCII')) {
} else {
}
keeps it clean.

Hi i dont have this code "$header .= 'Reply-To: =?UTF-8?B?' . base64_encode($this->sender) . '?= <' . $this->reply_to . '>' . PHP_EOL;"

i have this code "$header .= 'Reply-To: =?UTF-8?B?' . base64_encode($this->reply_to) . '?= <' . $this->reply_to . '>' . PHP_EOL;"

Im Running opencart 3.0.3.8

Newbie

Posts

Joined
Tue Jun 30, 2015 4:44 pm
Who is online

Users browsing this forum: Google [Bot], neutrimous and 216 guests