Witajcie, wiem że wątek został poruszony dość ogólnie mimo wszystko myślę, że doświadczeni programiści będą wiedzieć skąd mogą takie problemy się pojawiać.
Otóż pobrałem z tej strony skrypt do wysyłania maili - próbuję sam stworzyć sklep, dlatego małymi krokami buduję go od ponad roku: https://www.prestashop.com/forums/topic/284818-free-module-standalone-version-newsletter-modul-emailer-for-prestashop-15-14/
Wszystko działa jak należy, mimo wszystko gdy dodaję do treści maila zdjęcie to w wiadomości, która przychodzi do mnie to zdjęcie nie jest wyświetlane. Zaglądałem do kodu źródłowego wiadomości i widzę, że kod odpowiedzialny za zdjęcie wygląda tak:
<img src=\"http://nazwa_domeny.pl/img/cms/baner.png\" alt=\"test\" align=\"left\">
Przez te ukośniki zdjęcia nie są widoczne. Może wiecie co może być przyczyną tego typu zachowań ?
Szukałem informacji na ten temat i znalazłem, że funkcja addslashes może być za to odpowiedzialna. Przeszukałem wszystkie pliki gdzie występuje ta funkcja i znajduje się ona w jednym miejscu ale nie wiem czy to jest przyczyną i jak ją zmodyfikować.
public function encodeHeader($str, $position = 'text')
{
$x = 0;
switch (strtolower($position)) {
case 'phrase':
if (!preg_match('/[\200-\377]/', $str)) {
// Can't use addslashes as we don't know what value has magic_quotes_sybase
$encoded = addcslashes($str, "\0..\37\177\\\"");
if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) {
return ($encoded);
} else {
return ("\"$encoded\"");
}
}
$x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
break;
/** @noinspection PhpMissingBreakStatementInspection */
case 'comment':
$x = preg_match_all('/[()"]/', $str, $matches);
// Intentional fall-through
case 'text':
default:
$x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
break;
}
if ($x == 0) { //There are no chars that need encoding
return ($str);
}
$maxlen = 75 - 7 - strlen($this->CharSet);
// Try to select the encoding which should produce the shortest output
if ($x > strlen($str) / 3) {
//More than a third of the content will need encoding, so B encoding will be most efficient
$encoding = 'B';
if (function_exists('mb_strlen') && $this->hasMultiBytes($str)) {
// Use a custom function which correctly encodes and wraps long
// multibyte strings without breaking lines within a character
$encoded = $this->base64EncodeWrapMB($str, "\n");
} else {
$encoded = base64_encode($str);
$maxlen -= $maxlen % 4;
$encoded = trim(chunk_split($encoded, $maxlen, "\n"));
}
} else {
$encoding = 'Q';
$encoded = $this->encodeQ($str, $position);
$encoded = $this->wrapText($encoded, $maxlen, true);
$encoded = str_replace('=' . self::CRLF, "\n", trim($encoded));
}
$encoded = preg_replace('/^(.*)$/m', " =?" . $this->CharSet . "?$encoding?\\1?=", $encoded);
$encoded = trim(str_replace("\n", $this->LE, $encoded));
return $encoded;
}