Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to parse multipart MIME email strings #255

Open
wants to merge 9 commits into
base: 2.26.x
Choose a base branch
from

Commits on Nov 21, 2023

  1. Add the ability to parse multipart MIME email strings

    This change adds the ability to instantiate Message objects from
    multipart MIME email strings.
    
    Most of the functionality was already there; there was even a commented
    out stub that outlined the start of what was required. However, I think
    because the supporting functionality was lacking in laminas-mime, it was
    not implemented.
    
    Signed-off-by: Matthew Setter <matthew@matthewsetter.com>
    settermjd committed Nov 21, 2023
    Configuration menu
    Copy the full SHA
    89ca841 View commit details
    Browse the repository at this point in the history

Commits on Nov 23, 2023

  1. Update testCanParseMultipartEmail

    This change adds assertions for the content of the various parts of
    message. The intention is to be able to check deeper into a multipart
    message to confirm that it is as expected. As the underlying test data
    contains a PDF file, it adds the smalot/pdfparser to simplify working
    with PDF files.
    
    Signed-off-by: Matthew Setter <matthew@matthewsetter.com>
    settermjd committed Nov 23, 2023
    Configuration menu
    Copy the full SHA
    f2419f4 View commit details
    Browse the repository at this point in the history

Commits on Nov 30, 2023

  1. Refactor instantiation of mime messages

    From my understanding of the various specs, primarily RFC 1341, the
    existing functionality for setting message headers was wrong. Given
    that, I've made this change, which should bring it into line with the
    spec, corrects issues with the existing tests, and sets one existing
    test as skipped (for the time being).
    
    Firstly, it removes the functionality that sets headers on the main
    message from message sub-parts. Secondly, equally as importantly, it
    sets the required headers, along with their defaults, based on the
    message's composition. I won't get into detail here, as it's documented
    in the code and in the updates to the documentation.
    
    Finally, the change also cleans up some of the existing functionality as
    well, setting return types, as they're supported in the package's
    allowed PHP versions.
    
    Signed-off-by: Matthew Setter <matthew@matthewsetter.com>
    settermjd committed Nov 30, 2023
    Configuration menu
    Copy the full SHA
    c4da0a4 View commit details
    Browse the repository at this point in the history
  2. Update the documentation to reflect mime message composition changes

    This commit updates the relevant sections of the documentation to
    reflect the changes in how mime messages are created. It also does a
    little bit of cleaning up of the documentation as well.
    
    Signed-off-by: Matthew Setter <matthew@matthewsetter.com>
    settermjd committed Nov 30, 2023
    Configuration menu
    Copy the full SHA
    5bd5f72 View commit details
    Browse the repository at this point in the history
  3. Update composer.lock

    I think that I inadvertantly checked in a composer.lock file which
    referenced a local fork of laminas-mime that I was working on while
    patching the library. This change reverts that.
    
    Signed-off-by: Matthew Setter <matthew@matthewsetter.com>
    settermjd committed Nov 30, 2023
    Configuration menu
    Copy the full SHA
    f283ac4 View commit details
    Browse the repository at this point in the history
  4. Simplify test data

    After feedback from @MWOP, this change simplifies test data for testing
    the HTML part of an email. It removes SendGrid details, to ensure that
    the tests don't favour any given provider.
    
    Signed-off-by: Matthew Setter <matthew@matthewsetter.com>
    settermjd committed Nov 30, 2023
    Configuration menu
    Copy the full SHA
    927391a View commit details
    Browse the repository at this point in the history
  5. Add a series of iterators to simplify working with Message Parts

    This change adds three custom RecursiveIterator classes with the aim of
    simplifying working with message parts.
    
    - PartsIterator simplifies iterating over a recursive list of parts, as
      multipart mime email parts can themselves contain parts.
    - MessagePartFilterIterator is designed to use PartsIterator to filter
      out parts that are not the contents of a message, such as the plain
      text or HTML body.
    - AttachmentPartFilterIterator is designed to use PartsIterator to
      filter out parts that are not message attachments.
    
    Together, these iterators will help provide functionality for quickly
    retrieving a message's content and attachments, without leaving it to
    the user.
    
    Signed-off-by: Matthew Setter <matthew@matthewsetter.com>
    settermjd committed Nov 30, 2023
    Configuration menu
    Copy the full SHA
    33f94d0 View commit details
    Browse the repository at this point in the history
  6. Add utility functions for retrieving message content and attachments

    You can iterate over all of the message parts in the calling code and
    extract the plain text and HTML body, as well as the attachments.
    However, I thought that this would be something that people would do
    regularly; so much so such that adding utility functions for doing so
    might be a great productivity win for the package.
    
    The documentation's been updated to reflect these additions so that
    they're as visible as possible, and readily discoverable.
    
    Signed-off-by: Matthew Setter <matthew@matthewsetter.com>
    settermjd committed Nov 30, 2023
    Configuration menu
    Copy the full SHA
    e7d10b0 View commit details
    Browse the repository at this point in the history

Commits on Dec 7, 2023

  1. Merge branch '2.26.x' into add-multipart-support

    Signed-off-by: Matthew Setter <matthew@matthewsetter.com>
    settermjd committed Dec 7, 2023
    Configuration menu
    Copy the full SHA
    d4a1d4a View commit details
    Browse the repository at this point in the history