Selamlar,
Bir sistemim var. Duyuru girişi yapıldığı zaman kullanıcılara aynı zamanda mail atıyor.
Duyuru web üzerinde sorunsuz bir şekilde görüntülenebiliyor fakat PHPMailer ile gönderdiğim içerikteki resim linki problemli gözüküyor.
Outlook'dan mail'in kaynağını çektiğimde linkin başında, sonunda ve içeriğin belirli yerlerinde """ ibaresini görüyorum.
"htmlspecialchars($body)" ile """ içeriklerini silebiliyorum fakat bu şekilde yaptığım zaman ise Outlook'da <img> tag'i yazı halinde geliyor, örnek;
Outlook Mail Kaynak Kodu:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><center><img style="text-align: center;" src="https://cloud.domain.com.tr/test_turan/duyuru/assets/img/domain -logo-mail.png"></center>
<center><table>
<td valign="middle" align="center" style="width: 400px; padding-top: 20px;">
<h2 style="font-family: Arial;">Test Duyuru Sistemi</h2>
</td>
<td></td>
</table></center>
<center><table>
<td valign="middle" align="center" style="padding-top:20px; width: 400px;">
<p style="font-family: Arial;"><p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p>\n\n<p>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.</p>\n\n<p><img alt="\"\"" src="\"https://cloud.domain .com.tr/ckfinder/userfiles/images/2022-12-21%2012_33_21-Window.png\"" style="\"height:780px;" width:891px\?=""></p>\n</p>
</td>
</table></center>
<center><table>
<td valign="middle" align="center" style="width: 400px;">
<a href="cloud.domain.com.tr" style="font-family: Arial;">Devamını Oku</a>
</td>
</table></center>PHPMailer ile gönderdiğim kod;
<?php
require_once('config.php');
// Initialize the session
session_start();
//print_r($_SESSION);
//yetki kontrolü yap
if($_SESSION['duyuru_yetki'] != "1"){
header('Location: ../login.php');
session_destroy();
}
//bugünki tarih
$currentDate = date('Y-m-d');
// Check if the user is logged in, otherwise redirect to login page
if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true){
header("location: ../login.php");
exit;
}
ini_set('display_errors', 1); // Hata mesajlarını görüntülemeyi aktif hale getirin
error_reporting(E_ALL); // Tüm hata seviyelerini görüntüle
// Formdan gönderilen verileri alın
$title = mysqli_real_escape_string($conn, $_POST['title']);
$body = mysqli_real_escape_string($conn, $_POST['body']);
$category_id = mysqli_real_escape_string($conn, $_POST['category_id']);
$ozet = '
<center><img style="text-align: center;" src="https://cloud.domain.com.tr/test_turan/duyuru/assets/img/domain-logo-mail.png"></center>
<center><table>
<td valign="middle" align="center" style="width: 400px; padding-top: 20px;">
<h2 style="font-family: Arial;">'. $title .'</h2>
</td>
<td></td>
</table></center>
<center><table>
<td valign="middle" align="center" style="padding-top:20px; width: 400px;">
<p style="font-family: Arial;">'. htmlspecialchars($body) .'</p>
</td>
</table></center>
<center><table>
<td valign="middle" align="center" style="width: 400px;">
<a href="cloud.domain.com.tr" style="font-family: Arial;">Devamını Oku</a>
</td>
</table></center>
';
// Import PHPMailer classes into the global namespace
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
// Include PHPMailer library files
require 'src/Exception.php';
require 'src/PHPMailer.php';
require 'src/SMTP.php';
//require 'index.php';
// Create an instance of PHPMailer class
$mail = new PHPMailer;
// UTF-8
$mail->CharSet = 'UTF-8';
$mail->Encoding = 'base64';
// SMTP configuration
//$mail->IsSMTP(); //Çalışmazsa etkinleştir.
$mail->Host = 'domain';
$mail->SMTPAuth = true;
$mail->Username = 'mail';
$mail->Password = 'şifre';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
// Sender info
$mail->setFrom('mail', 'Duyuru Sistemi');
// Add a recipient
$mail->addAddress('mail');
$mail->addAddress('mail');
//$mail->addAddress('mail');
//cc bölümü
//$mail->addCC('mail');
// Email subject
$mail->Subject = 'Duyuru: '. $title .''; // İleti konusu
// Set email format to HTML
$mail->isHTML(true);
// Email body content
$mailContent = '';
$mail->Body = $ozet;