我正在使用PHP来将电子邮件存储在已发送的文件夹中。我在将URL存储在电子邮件中时遇到问题,因为当img标签src应该为id
和msgid
时,我将获得id=
和msgid=
。我已经研究了几个小时,由于将电子邮件存储在已发送的文件夹中时不断收到=
和,因此无法找到如何在html中存储
。
当我尝试这个时:
<?php
require_once "Mail.php";
require_once "Mail/mime.php";
require_once('Mail/IMAPv2.php');
// Connect to the server:
$username = 'myusername';
$password = '*************';
$sent = '{imap.example.com:993/imap/ssl/novalidate-cert}INBOX.Sent';
$sent_mailbox = imap_open($sent, $username, $password);
$from_email = $_POST['send_from'];
$to_email = $_POST['send_to'];
$subject = $_POST['emailsubject'];
$message = '<div id="emailMessage" class="row" style="padding: 5px 30px;margin-top: 12px;"><div><div dir="ltr"><img src="http://example.com/u/?id=1562453336&attid=0.2&msgid=1644988591229814716&view=attachment&display=view" width="452" height="302" class="CToWUd a6T" tabindex="0"><br><div><br></div><div><br></div><div><img src="http://example.com/u/?id=1562453336&attid=0.1&msgid=1644988591229814716&view=attachment&display=view" class="CToWUd"><br></div><div><br></div><div><br></div><div>
';
$messageID = sprintf("<%s.%s@%s>",
base_convert(microtime(), 10, 36),
base_convert(bin2hex(openssl_random_pseudo_bytes(8)), 16, 36),
'example.com');
imap_append($sent_mailbox, $sent,
"From: ".$from_email."r\n".
"To: ".$to_email."\r\n".
"Subject: ".$subject."\r\n".
"Date: ".date("r", strtotime("now"))."\r\n".
"Message-ID: ".$messageID."\r\n".
"MIME-Version: 1 \r\n".
"Content-Type: multipart/mixed; boundary=\"$boundary1\"\r\n".
"\r\n\r\n".
"--$boundary1\r\n".
"Content-Type: multipart/alternative; boundary=\"$boundary2\"\r\n".
"\r\n\r\n".
// ADD Plain text data
"--$boundary2\r\n".
"Content-Type: text/plain; charset=\"utf-8\"\r\n".
"Content-Transfer-Encoding: quoted-printable\r\n".
"\r\n\r\n".
$message."\r\n".
"\r\n\r\n".
// ADD Html content
"--$boundary2\r\n".
"Content-Type: text/html; charset=\"utf-8\"\r\n".
"Content-Transfer-Encoding: quoted-printable \r\n".
"\r\n\r\n".
$message."\r\n".
"\r\n\r\n".
"--$boundary1\r\n".
"\r\n\r\n".
// ADD attachment(s)
$attachment1.
"\r\n\r\n".
"--$boundary1--\r\n\r\n",
"\\Seen"
);
这里是ID旁边和msgid旁边
的显示,如下所示:
<img src="http://example.com/u/?id62453336&attid=0.2&msgid44988591229814716&view=attachment&display=view" width="452" height="302" class="CToWUd a6T">
我已经尝试过:
$message = html_entity_decode($message);
而且我也尝试过这个:
$message = htmlspecialchars($message);
没有什么区别,所以我不知道该怎么办。
[当我在img标签url中有id=
和msgid=
而没有显示和
时,可以为我显示如何将HTML电子邮件存储在已发送文件夹中的示例?
谢谢。
尝试这样的事情
$message= nl2br($message);