【问题标题】:I am using Amazon SES. How will I track the bounce email messages using PHP?我正在使用亚马逊 SES。我将如何使用 PHP 跟踪退回的电子邮件?
【发布时间】:2013-10-27 07:36:48
【问题描述】:

我正在使用 Amazon SES 服务。但我不明白如何使用 PHP 跟踪退回的电子邮件并将这些电子邮件日志存储在数据库中。我有一个亚马逊博客的参考链接,但那里给出的解决方案是在 C#(http://sesblog.amazon.com/post/TxJE1JNZ6T9JXK/Handling-Bounces-and-Complaints) 上。 需要帮助和帮助。 谢谢。

【问题讨论】:

标签: php amazon-ses email-bounces


【解决方案1】:

为退回和投诉创建一个 SNS 主题并将其链接到您的 SES(转到查看详细信息选项卡 - 编辑配置 - 链接相应的 SNS 投诉和退回主题)。

确保根据您的要求将您创建的 SNS 主题订阅到您的邮件 ID 或 http/s。每当 SES 消息被退回或标记投诉时,您将收到 JSON 数据,稍后可以根据您的需要进行处理。

以下是非常有用的 AWS 网络研讨会:https://www.youtube.com/watch?v=n3Fr0bCsIvo

【讨论】:

    【解决方案2】:

    要遵循的步骤

    1. 创建 SNS 主题

    2. 创建订阅

    3. 确认订阅

    代码

    class AmazonController extends Controller
    {
     public function handleBounceOrComplaint(Request $request)
     {
       Log::info($request->json()->all());
       $data = $request->json()->all();
       if($request->json('Type') == 'SubscriptionConfirmation')
       Log::info("SubscriptionConfirmation came at: ".$data['Timestamp']);
       if($request->json('Type') == 'Notification'){
       $message = $request->json('Message');
       switch($message['notificationType']){
        case 'Bounce':
          $bounce = $message['bounce'];
          foreach ($bounce['bouncedRecipients'] as $bouncedRecipient){
            $emailAddress = $bouncedRecipient['emailAddress'];
            $emailRecord = WrongEmail::firstOrCreate(['email' => $emailAddress, 'problem_type' => 'Bounce']);
            if($emailRecord){
              $emailRecord->increment('repeated_attempts',1);
            }
          }
          break;
          case 'Complaint':
          $complaint = $message['complaint'];
          foreach($complaint['complainedRecipients'] as $complainedRecipient){
            $emailAddress = $complainedRecipient['emailAddress'];
            $emailRecord = WrongEmail::firstOrCreate(['email' => $emailAddress, 'problem_type' => 'Complaint']);
            if($emailRecord){
              $emailRecord->increment('repeated_attempts',1);
            }
          }
          break;
          default:
          // Do Nothing
          break;
        }
      }
      return Response::json(['status' => 200, "message" => 'success']);
     }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-25
      • 1970-01-01
      • 2013-04-24
      • 2012-06-21
      • 1970-01-01
      • 2015-06-15
      • 2011-07-21
      • 2017-04-14
      相关资源
      最近更新 更多