$output .= '<p><img src="cid:' . $linkID . '" alt="graph" /></p>';
在哪里?
$linkID
与下面函数中使用的值相同。
public function sendEmail($emailAddress)
{
$random_hash = md5(date('r', time()));
$htmlString = $this->getHTML($random_hash);
$message = "--mixed-$random_hash\n";
$message .= 'Content-Type: multipart/alternative; boundary="alt-' . $random_hash . '"' . "\n\n";
$message .= 'MIME-Version: 1.0' . "\n";
$message .= '--alt-' . $random_hash . "\n";
$message .= 'Content-Type: text/plain; charset="iso-8859-1"' . "\n";
$message .= 'Content-Transfer-Encoding: 7bit' . "\n\n";
// text message
$message .= strip_tags($htmlString) . "\n\n";
$message .= '--alt-' . $random_hash . "\n";
$message .= 'Content-Type: text/html; charset="iso-8859-1"' . "\n";
// $message .= 'MIME-Version: 1.0' . "\n";
$message .= 'Content-Transfer-Encoding: 7bit' . "\n\n";
// html message
$message .= $htmlString . "\n\n";
$message .= '--alt-' . $random_hash . '--' . "\n";
// graph image
if($this->selectedGraph != 0)
{
$graphString = $this->getGraph();
$graphString = chunk_split(base64_encode($graphString));
$linkID = 'graph-' . $random_hash . '-image';
$message .= '--mixed-' . $random_hash . "\n";
$message .= 'MIME-Version: 1.0' . "\n";
$message .= 'Content-Transfer-Encoding: base64' . "\n";
$message .= 'Content-ID: ' . $linkID . "\n";
$message .= 'Content-Type: image/gif; name="graph.gif"' . "\n";
$message .= 'Content-Disposition: attachment' . "\n\n";
$message .= $graphString;
$message .= '--mixed-' . $random_hash . '--' . "\n";
}
else
{
$message .= '--mixed-' . $random_hash . '--' . "\n";
}
$headers = 'From: ' . $this->from. "\r\nReply-To: " . $this->replyto;
$headers .= "\r\nContent-Type: multipart/related; boundary=\"mixed-" . $random_hash . "\"\r\nMIME-Version: 1.0";
$flags = '-f ' . BOUNCED_EMAIL_ADDRESS;
return mail($emailAddress, $this->subject, $message, $headers, $flags);
}
是否值得做是另一个问题。如果附加图像,则使用带宽发送消息。也许你最好一次全部使用带宽,而不是分散使用?也许不是。
我没有使用附加的图像,直到我必须发出一个电子邮件
不同的
向每个收件人发送图像。我不打算在服务器上存储和管理所有这些图像(并尝试对它们进行唯一命名)。