Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

Кодирование тела письма


thentru
 Share

Recommended Posts

Почему в движке само сообещёние письма (html, текст) не кодируется в base64 + chunk_split или quoted-printable.
Есть ли какой-то обещёпринятый синдарт?


Один из заказликов столкнулся с проблемой ломаной кодировки в письме

https://prnt.sc/kotr0u
При присмотре исходника тела письма видно, что строка переносится на 998 символе, при этом некорректно

Link to comment
Share on other sites


Если бы покупатели умели всивлять текст в способ оплаты)

Link to comment
Share on other sites


  • 1 month later...
  • 1 year later...

прилина в том, что при потому чтольшой строке происходит ее разбивка для соответствия синдарту RFC 821 (лимит 1000 символов на строку)

 

только разбивка средствами движка в system\library\mail.php сгделана некорректно - без учеи многобайтовых кодировок и самого меси разбивки (т.е. может рубить и посреди тегов и посреди ссылки)

что и приводит к появлению кракозябр в письмах с длинными строками

  • +1 1
Link to comment
Share on other sites

В 13.10.2018 в 15:39, shoputils сказал:

 

а для ocStore 3 подскажете куда капать? Вторую замену я нашел, а вот этого кода им нет: 

 

	public function setHtml($html) {
		$this->html = $html;
		$this->html = chunk_split(base64_encode($html));
	}

Файлы прикрепил. Буду благодарен за помощь

smtp.php mail.php

Link to comment
Share on other sites


  • 1 year later...

Тоже столкнулся с пропаданием символов в письмах. Происходит из-за неправильного переноса.

Фикс для OC 3.0.3.7

 

1) Файл:

system/library/mail.php

Меняем:

public function setHtml($html) {
	$this->html = $html;
}

На:

public function setHtml($html) {
	$this->html = chunk_split(base64_encode($html));
}

 

 

 2) Файл:

system/library/mail/mail.php

Меняем:

$message .= 'Content-Transfer-Encoding: 8bit' . PHP_EOL . PHP_EOL;
$message .= $this->html . PHP_EOL;

На:

$message .= 'Content-Transfer-Encoding: base64' . PHP_EOL . PHP_EOL;
$message .= $this->html . PHP_EOL;

 

 

 3) Файл:

system/library/mail/smtp.php

Меняем:

$message .= 'Content-Transfer-Encoding: 8bit' . PHP_EOL . PHP_EOL;
$message .= $this->html . PHP_EOL;

На:

$message .= 'Content-Transfer-Encoding: base64' . PHP_EOL . PHP_EOL;
$message .= $this->html . PHP_EOL;

 

 

Модификатор:

<modification>
	<name>Fix ru line breaks in email html</name>
	<version>1.0</version>
	<code>fix_ru_base64</code>
	
	<file path="system/library/mail.php">
		<operation>
			<search><![CDATA[$this->html = $html;]]></search>
			<add position="replace"><![CDATA[$this->html = chunk_split(base64_encode($html));]]></add>
		</operation>
	</file>
	
	<file path="system/library/mail/mail.php">
		<operation>
			<search index="2"><![CDATA[$message .= 'Content-Transfer-Encoding: 8bit' . PHP_EOL . PHP_EOL;]]></search>
			<add position="replace"><![CDATA[$message .= 'Content-Transfer-Encoding: base64' . PHP_EOL . PHP_EOL;]]></add>
		</operation>
	</file>
	
	<file path="system/library/mail/smtp.php">
		<operation>
			<search index="2"><![CDATA[$message .= 'Content-Transfer-Encoding: 8bit' . PHP_EOL . PHP_EOL;]]></search>
			<add position="replace"><![CDATA[$message .= 'Content-Transfer-Encoding: base64' . PHP_EOL . PHP_EOL;]]></add>
		</operation>
	</file>
	
</modification>

 

fix-ru-line-breaks-in-email-html.ocmod.zip

  • +1 4
Link to comment
Share on other sites


  • 1 month later...
В 22.09.2021 в 18:02, reforket сказал:

Тоже столкнулся с пропаданием символов в письмах. Происходит из-за неправильного переноса.

Фикс для OC 3.0.3.7

 

1) Файл:

system/library/mail.php

Меняем:

public function setHtml($html) {
	$this->html = $html;
}

На:

public function setHtml($html) {
	$this->html = chunk_split(base64_encode($html));
}

 

 

 2) Файл:

system/library/mail/mail.php

Меняем:

$message .= 'Content-Transfer-Encoding: 8bit' . PHP_EOL . PHP_EOL;
$message .= $this->html . PHP_EOL;

На:

$message .= 'Content-Transfer-Encoding: base64' . PHP_EOL . PHP_EOL;
$message .= $this->html . PHP_EOL;

 

 

 3) Файл:

system/library/mail/smtp.php

Меняем:

$message .= 'Content-Transfer-Encoding: 8bit' . PHP_EOL . PHP_EOL;
$message .= $this->html . PHP_EOL;

На:

$message .= 'Content-Transfer-Encoding: base64' . PHP_EOL . PHP_EOL;
$message .= $this->html . PHP_EOL;

 

 

Модификатор:

<modification>
	<name>Fix ru line breaks in email html</name>
	<version>1.0</version>
	<code>fix_ru_base64</code>
	
	<file path="system/library/mail.php">
		<operation>
			<search><![CDATA[$this->html = $html;]]></search>
			<add position="replace"><![CDATA[$this->html = chunk_split(base64_encode($html));]]></add>
		</operation>
	</file>
	
	<file path="system/library/mail/mail.php">
		<operation>
			<search index="2"><![CDATA[$message .= 'Content-Transfer-Encoding: 8bit' . PHP_EOL . PHP_EOL;]]></search>
			<add position="replace"><![CDATA[$message .= 'Content-Transfer-Encoding: base64' . PHP_EOL . PHP_EOL;]]></add>
		</operation>
	</file>
	
	<file path="system/library/mail/smtp.php">
		<operation>
			<search index="2"><![CDATA[$message .= 'Content-Transfer-Encoding: 8bit' . PHP_EOL . PHP_EOL;]]></search>
			<add position="replace"><![CDATA[$message .= 'Content-Transfer-Encoding: base64' . PHP_EOL . PHP_EOL;]]></add>
		</operation>
	</file>
	
</modification>

 

fix-ru-line-breaks-in-email-html.ocmod.zip 481 \u0411 · 3 downloads

 

Спасипотому что! Версия ocStore 3.0.3.7 - всё помогло!

Тоже пропадали буквы или появлялись в середине слова символы ?%? в форме письма покупателю и администратору.

 

Link to comment
Share on other sites


  • 4 weeks later...
В 22.09.2021 в 18:02, reforket сказал:

Тоже столкнулся с пропаданием символов в письмах. Происходит из-за неправильного переноса.

Фикс для OC 3.0.3.7

 

1) Файл:

system/library/mail.php

Меняем:

public function setHtml($html) {
	$this->html = $html;
}

На:

public function setHtml($html) {
	$this->html = chunk_split(base64_encode($html));
}

 

 

 2) Файл:

system/library/mail/mail.php

Меняем:

$message .= 'Content-Transfer-Encoding: 8bit' . PHP_EOL . PHP_EOL;
$message .= $this->html . PHP_EOL;

На:

$message .= 'Content-Transfer-Encoding: base64' . PHP_EOL . PHP_EOL;
$message .= $this->html . PHP_EOL;

 

 

 3) Файл:

system/library/mail/smtp.php

Меняем:

$message .= 'Content-Transfer-Encoding: 8bit' . PHP_EOL . PHP_EOL;
$message .= $this->html . PHP_EOL;

На:

$message .= 'Content-Transfer-Encoding: base64' . PHP_EOL . PHP_EOL;
$message .= $this->html . PHP_EOL;

 

 

Модификатор:

<modification>
	<name>Fix ru line breaks in email html</name>
	<version>1.0</version>
	<code>fix_ru_base64</code>
	
	<file path="system/library/mail.php">
		<operation>
			<search><![CDATA[$this->html = $html;]]></search>
			<add position="replace"><![CDATA[$this->html = chunk_split(base64_encode($html));]]></add>
		</operation>
	</file>
	
	<file path="system/library/mail/mail.php">
		<operation>
			<search index="2"><![CDATA[$message .= 'Content-Transfer-Encoding: 8bit' . PHP_EOL . PHP_EOL;]]></search>
			<add position="replace"><![CDATA[$message .= 'Content-Transfer-Encoding: base64' . PHP_EOL . PHP_EOL;]]></add>
		</operation>
	</file>
	
	<file path="system/library/mail/smtp.php">
		<operation>
			<search index="2"><![CDATA[$message .= 'Content-Transfer-Encoding: 8bit' . PHP_EOL . PHP_EOL;]]></search>
			<add position="replace"><![CDATA[$message .= 'Content-Transfer-Encoding: base64' . PHP_EOL . PHP_EOL;]]></add>
		</operation>
	</file>
	
</modification>

 

fix-ru-line-breaks-in-email-html.ocmod.zip 481 \u0411 · 8 downloads

 

Немного дорилиил Ваш модификатор.
Для текстовых писем тоже добавил base64.
 

fix-ru-line-breaks-in-email-html.ocmod.zip

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.