使用mail()在电子邮件中发送多个图像

时间:2019-05-27 07:32:18

标签: php email

我以url格式将图像存储在数据库中。现在我想使用php中的mail()发送带有多个图像的邮件

$sql11 = "SELECT `photo_id`, `project_id`, `map_id`, `map_flag`, `user_id`, `photo_path`, `pdf_path`, `created_at`, `modified_at` FROM `photos` WHERE map_flag='Task' and map_id='$task_id'";
$rl    = $conn->query($sql11);
while ($res11 = mysqli_fetch_assoc($rl)) {
    $array[] = [$res11['photo_path']];
}
$str     = implode(',', $array);
$message = $message_content . "\n" . "\n" . "\n" . $message1 . "\n" . $message2 . "\n" . $message3 . "\n" . $message4 . "\n" . $message5 . "\n" . $message6 . "\n" . $array . "\n" . $message8 . "\n";
$from    = "123@test.com";
$headers = 'From: ' . $from . "\r\n";
$result  = mail($to, $subject, $message, $headers);

1 个答案:

答案 0 :(得分:0)

首先,您需要告诉电子邮件应用程序这是html。这可以通过添加行来完成

$headers .= "Content-type: text/html; charset=UTF-8";

接下来,photo_path是什么?是否还包含完整网址或相对网址?您需要设置完整的网址,即http://example.com/{$res11['photo_path']}

相关问题