【问题标题】:Send attachment from s3 bucket using Mailgun使用 Mailgun 从 s3 存储桶发送附件
【发布时间】:2025-11-28 13:45:01
【问题描述】:

尝试发送嵌入内嵌图像的电子邮件。只有文件不在服务器上,它位于 S3 存储桶中。如何才能做到这一点?标准 API 似乎没有将图像读入电子邮件。

【问题讨论】:

    标签: mailgun inline-attachments


    【解决方案1】:
    require 'vendor/autoload.php';
    use Mailgun\Mailgun;
    # Instantiate the client.
    $mgClient = Mailgun::create('PRIVATE_API_KEY', 'https://API_HOSTNAME');
    $domain = "YOUR_DOMAIN_NAME";
    $params = array(
          'from'    => 'Excited User <YOU@YOUR_DOMAIN_NAME>',
          'to'      => 'bob@example.com',
          'subject' => 'Hello',
          'text'    => 'Testing some Mailgun awesomness!',
          'html'    => '<html>Inline image: <img src="cid:test.jpg"></html>',
          'inline' => array(
              array('filePath' => '/path/to/image.jpg'))
        );
    
      # Make the call to the client.
      $result = $mgClient->messages()->send($domain, $params);
    

    通过使用内联参数,您可以使用正确的路径发送图像。

    【讨论】:

      最近更新 更多