sisimai / rb-sisimai

Mail Analyzing Interface for email bounce: A Ruby library to parse RFC5322 bounce mails and generating structured data as JSON from parsed results. Ruby version of Sisimai: an error mail analyzer.
https://libsisimai.org/
Other
83 stars 19 forks source link

Apple opt out email categorized as "vacation" #279

Closed mnmallea closed 5 months ago

mnmallea commented 5 months ago

When an Apple email user unsubscribes from an email list using the unsubscribe button in the email client, Apple sends an automated opt out message like this one:

Date: Thu, 2 May 2024 17:48:55 +0000 (UTC)
From: example@icloud.com
Reply-To: example@icloud.com
To: opt-out-100731.e75std53hz8rnmy4r@example.org
Message-ID: <898B6152-36BC-4F4B-ABF8-2694A88CB5FC@icloud.com>
Subject: unsubscribe
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com;
    s=1a1hai; t=1714672136; bh=63IYtxpNtEan90vzJQT9iqnMeWHy9rlx8iFLnco1rRc=;
    h=Content-Type:From:Mime-Version:Date:Subject:Message-Id:To;
    b=AoovfvadwxCx8Pp5yD62kw1AcKMQV32RhSrBsyw4qLr/CVsQo1tIh+xCUPdI7So9i
     paxzn20YdVvHuP3f8CxT/q3x9WaQV3NDAmbbQumYwOpJk7yNXRkuWNjIlt6isZM0tb
     FK8v+Tq3j3Va83mZ6OeR8ZjvfY8ImjewEOTEZ79sNxToaaHvRuDWRbzt4uaktRuL44
     j1wEjiKxgy6f7bOC2XJyRaf41BtCm4V6TGtcBF9hOEMzn6LulaLgashs3yGQ92wkb9
     OLSy1uP0iA4nj/qAM+QaauAFzmqYmqa9r7rUFCjqf01q4gvn1QfO4QVqiRQXiMXc8e
     QPSqskbSbsIQA==
X-Proofpoint-GUID: fiybgv3DewxSxApGH8GnpeSw3OZld4ll
Auto-Submitted: auto-replied
X-Apple-Unsubscribe: true
X-Proofpoint-ORIG-GUID: fiybgv3DewxSxApGH8GnpeSw3OZld4ll
X-Virus-Status: Clean

Apple Mail sent this email to unsubscribe from the message =E2=80=9Cunsubsc=
ribe=E2=80=9D.

After analyzing it with sisimai I got this response:

➜  ~ ruby -rsisimai -e 'print Sisimai.dump($*.shift, vacation: true)' ./apple-opt-out-example.eml | json_pp 
[
   {
      "action" : "",
      "addresser" : "opt-out-100731.e75std53hz8rnmy4r@example.org",
      "alias" : "",
      "catch" : "",
      "deliverystatus" : "",
      "destination" : "icloud.com",
      "diagnosticcode" : "Apple Mail sent this email to unsubscribe from the message “unsubscribe”.",
      "diagnostictype" : "",
      "feedbacktype" : "",
      "hardbounce" : false,
      "lhost" : "",
      "listid" : "",
      "messageid" : "",
      "origin" : "./apple-opt-out-example.eml",
      "reason" : "vacation",
      "recipient" : "example@icloud.com",
      "replycode" : "",
      "rhost" : "",
      "senderdomain" : "example.org",
      "smtpagent" : "RFC3834",
      "smtpcommand" : "",
      "subject" : "",
      "timestamp" : 1714672135,
      "timezoneoffset" : "+0000",
      "token" : "a68c9c71e8103ff7a1fc5846e7808fa8fb06954f"
   }
]

I think that it shouldn't be classified with vacation reason as the email text doesn't say anything about being on vacation or out of office.

azumakuniyuki commented 5 months ago

@mnmallea Thank you for the report. I agree that unsubscribe notifications should be treated as "feedback" (optout) rather than "vacation". I will try to make a correction so that they can be classified correctly.

azumakuniyuki commented 5 months ago

@mnmallea The code implemented at #280 returns the following result:

% ruby -Ilib -rsisimai -e 'puts Sisimai.dump($*.shift)' ./apple-feedback-unsubscribe.eml | jq
[
  {
    "action": "",
    "alias": "",
    "catch": "",
    "deliverystatus": "",
    "destination": "icloud.com",
    "diagnosticcode": "",
    "diagnostictype": "",
    "feedbacktype": "opt-out",
    "lhost": "",
    "listid": "",
    "messageid": "",
    "origin": "./apple-feedback-unsubscribe.eml",
    "reason": "feedback",
    "replycode": "",
    "rhost": "",
    "senderdomain": "example.org",
    "smtpagent": "Feedback-Loop",
    "smtpcommand": "",
    "subject": "",
    "timezoneoffset": "+0000",
    "token": "a68c9c71e8103ff7a1fc5846e7808fa8fb06954f",
    "hardbounce": false,
    "addresser": "opt-out-100731.e75std53hz8rnmy4r@example.org",
    "recipient": "example@icloud.com",
    "timestamp": 1714672135
  }
]
mnmallea commented 5 months ago

Thank you @azumakuniyuki! That output looks good