本文介绍了使用亚马逊 SES 发送带附件的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用亚马逊 SES API 发送包含附件(pdf 文件)的电子邮件.

I am trying to send an email that contains an attachment (a pdf file) using the amazon SES API.

我使用的是 Symfony2,所以我在我的项目中包含了 AmazonWebServiceBundle.我可以使用以下代码轻松发送一封简单的电子邮件(没有附件):

I am using Symfony2 so I included the AmazonWebServiceBundle in my project.I can send a simple email (that has no attachment) pretty easily with the following code:

$ses = $this->container->get('aws_ses');
$recip = array("ToAddresses"=>array("[email protected]"));
$message = array("Subject.Data"=>"My Subject","Body.Text.Data"=>"My Mail body");
$result = $ses->send_email("[email protected]",$recip, $message);

不幸的是,要发送带附件的电子邮件,我需要使用 sendRawEmail 函数而不是 send_email 函数.

Unfortunately, to send an email with attachment, i need to use the sendRawEmail function instead of the send_email function.

我无法找到如何使用此功能,有人可以帮忙吗?

I am unable to find how to use this function, could anybody help?

推荐答案

经过多次尝试,我得出的结论是,直接从代码向 Amazon SES 发送电子邮件太痛苦了.

After many tries, I got to the conclusion that sending emails to Amazon SES directly from the code is too much pain.

所以我没有更改代码中的任何内容,而是配置了我的 postfix 服务器.

So I didn't change a thing in the code and configured my postfix server instead.

我遵循了这个程序:http://docs.amazonwebservices.com/ses/latest/DeveloperGuide/SMTP.MTA.Postfix.html 并使用 STARTTLS 配置集成.

I followed this procedure: http://docs.amazonwebservices.com/ses/latest/DeveloperGuide/SMTP.MTAs.Postfix.html and configured integration using STARTTLS.

我不得不在 Amazon 控制台中询问 SMTP 凭证.

I had to ask for SMTP credentials in the Amazon console.

现在一切正常,电子邮件已通过 Amazon SES 正确发送.

Now it's working fine, emails are sent properly through Amazon SES.

这篇关于使用亚马逊 SES 发送带附件的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-08 11:54