使用带有 PHP 的 mailgun 从收到的电子邮件中获取附件

Fetching attachments from incoming emails using mailgun with PHP

我正在使用 mailgun 来解析传入的电子邮件。 mailgun 将解析的电子邮件发送到 URL (https://example.com/email)。

我可以获取发件人、收件人、主题、正文等。但是我无法获取附件。

下面是我的代码,它 returns 是一个空值。

$file = addslashes(file_get_contents($this->input->post('attachment-1'))['name']);

$result = $this->tickets_model->saving_files($file);

请帮帮我。

谢谢。

我实现它的方法是使用 CI 上传库先上传文件然后解析它。

$config['file_name']  = 'filename';
$config['upload_path'] = '/upload/path';
$this->load->library('upload', $config);
if (!$this->upload->do_upload('attachment-1')) {
  // fail
} else {
  // success
}