【发布时间】:2021-09-29 04:24:08
【问题描述】:
我正在尝试使用 Sendgrid 入站解析,并且我的脚本工作正常。 webhook 被执行,我可以将消息保存到我们的应用程序数据库中。现在我有一个关于如何解析附件的问题。我已经研究了一段时间没有运气。在入站请求中有一个附件信息,其中包含有关附件的信息,但它实际存储在哪里?或者如果可能的话,我如何检索以将其存储在我们的服务器上或在线查看?
谢谢
$html = $_POST['html'];
$recipient = $_POST['to'];
$subject = $_POST['subject'];
$envelope = json_decode($_POST['envelope']);
$sender = $envelope->from;
$user = -1;
$created_at = date('Y-m-d H:i:s');
$attachments = $_POST['attachments'];
if($attachments > 0)
{
$attachment_info = json_decode($_POST['attachment-info'], true);
for($i = 1; $i <= $attachments; $i++)
{
//process attachments how???
$file = $attachment_info['attachment'.$i];
// {"filename":"shutterstock_745545163.jpg","name":"shutterstock_745545163.jpg","type":"image/jpeg","content-id":"ii_ku4rffz40"}
//what to I do whit this info? how do I retrieve the attachment from this emial??
}
}
$params = [
'type' => 'email',
'customer_id' => get_customer($sender),
'direction' => 'in',
'sender' => $sender,
'recipient' => $recipient,
'subject' => $subject,
'message' => $html,
'status' => 'delivered',
'user' => 0,
];
//process email
//this stores email into DB
process_email($params);
【问题讨论】: