I have an issue when use SMTP as send mails at opencart
https://prnt.sc/1rue7mp , https://prnt.sc/1rue9og
as same here if I use mail() it works fine but if I enable SMTP got an error at encoding message as the previous screen
posting.php?mode=quote&f=161&p=674540 ,, How to solve that database and language encoding well as utf8
source of message which have issue at encoding
https://prnt.sc/1rue0ku have utf8 correctly
Open version is 3.0.2.0
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
The posted fix never worked. But this one might help.
https://github.com/opencart/opencart/pull/9460/files
instead of this:
Code: Select all
foreach ($lines as $line) {
$results = str_split($line, 998);
Code: Select all
// message splitting length adjustment based on encoding
$length = (mb_detect_encoding($message, mb_detect_order(), true) == 'ASCII') ? 998 : 249;
foreach ($lines as $line) {
// split the line
$results = str_split($line, $length);
...
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
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
That will make things worse. Splitting the data into smaller chunks just increases the chance that the split occurs in the middle of a multi-byte character.by mona wrote: ↑Mon Sep 13, 2021 11:32 pmyou can try this
instead of this:Code: Select all
foreach ($lines as $line) { $results = str_split($line, 998);
Code: Select all
// message splitting length adjustment based on encoding $length = (mb_detect_encoding($message, mb_detect_order(), true) == 'ASCII') ? 998 : 249; foreach ($lines as $line) { // split the line $results = str_split($line, $length); ...
Code: Select all
$lines = explode("\n", $message);
$length = 998;
foreach ($lines as $line) {
$results = array();
$line_len = mb_strlen($line);
// split the line on characters instead of bytes if needed.
while ($line_len) {
$results[] = mb_substr($line,0,$length,"UTF-8");
$line = mb_substr($line,$length,$line_len,"UTF-8");
$line_len = mb_strlen($line);
}
foreach ($results as $result) {
if (substr(PHP_OS, 0, 3) != 'WIN') {
fputs($handle, $result . "\r\n");
} else {
fputs($handle, str_replace("\n", "\r\n", $result) . "\r\n");
}
}
}
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
That is still wrong. The 998 limit is in bytes. mb_substr works in characters and could return a string longer than 998 bytes, as each character could be up to 4 bytes. You could set the length to 249 (998 / 4).by mona wrote: ↑Tue Sep 14, 2021 6:34 pmyou can also use:Code: Select all
$lines = explode("\n", $message); $length = 998; foreach ($lines as $line) { $results = array(); $line_len = mb_strlen($line); // split the line on characters instead of bytes if needed. while ($line_len) { $results[] = mb_substr($line,0,$length,"UTF-8"); $line = mb_substr($line,$length,$line_len,"UTF-8"); $line_len = mb_strlen($line); } foreach ($results as $result) { if (substr(PHP_OS, 0, 3) != 'WIN') { fputs($handle, $result . "\r\n"); } else { fputs($handle, str_replace("\n", "\r\n", $result) . "\r\n"); } } }
I think it would just be easier to encode as base64, which is not multi-byte, as already done in 3.0.3.8.
https://github.com/opencart/opencart/pull/9460/files
It is an alternative suggestion, maybe not perfect, but one which may be useful to someone in light of the above.
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
Have a read of the RFC. https://datatracker.ietf.org/doc/html/r ... tion-2.1.1
Whereas a unnecessary base64 encoded message MIGHT be weighted towards spam.
Conclusion - issue not resolved
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
Send a plain text via SMTP and if that works its the HTML.
Then you need to look at what is causing that HTML to be so FUBARED
I disagree. One is in violation of the standards and will cause issues. The other unlikely to be a issue as encoding an 8-bit or multi-byte character set, shouldn't be treated as unnecessary.
Users browsing this forum: Bing [Bot] and 334 guests