Parse MIME Messages from your S3 Bucket

Mar 17, 2020 1 minute read

You can use this to parse incomming messages to a mailbox and then import them into a ticketing system or blog, etc.

You check out the Github repository

Installation

Require the package with composer.

1composer require onethirtyone/aws-s3-mime-handler

You'll also need to make sure your AWS environment variables are set

1AWS_ACCESS_KEY_ID=
2AWS_SECRET_ACCESS_KEY=
3AWS_DEFAULT_REGION=
4AWS_BUCKET=

Usage

The MessageCollector facade will return a collection of OneThirtyOne\Mime\Message instances. Each of these instances is a fully parsed MIME message from your bucket. You can access the properties:

1MessageCollector::fromBucket()->each(function ($message) {
2 $message->id; // The message file name
3 $message->to; // Message recipient
4 $message->from; // Message Sender
5 $message->subject; // Message Subject
6 $message->body; // The body of the message (plain text)
7});

You can delete a message by calling the delete() method on a message object

1$message = MessageCollector::fromBucket()->first();
2 
3$message->delete();

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change

Please make sure to update tests as appropriate.

License

MIT