All Projects → staktrace → mailparse

staktrace / mailparse

Licence: 0BSD license
Rust library to parse mail files

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to mailparse

finny.rs
Finite State Machines for Rust
Stars: ✭ 48 (-67.57%)
Mutual labels:  rust-library
hermes
Automates programmables à réaction aux échanges électroniques depuis une boîte IMAP4
Stars: ✭ 15 (-89.86%)
Mutual labels:  mail
rabe
rabe is an Attribute Based Encryption library, written in Rust
Stars: ✭ 52 (-64.86%)
Mutual labels:  rust-library
scripts
A collection of random scripts I coded up
Stars: ✭ 17 (-88.51%)
Mutual labels:  mail
gopistolet
Mailserver written in Go
Stars: ✭ 59 (-60.14%)
Mutual labels:  mail
homebridge-messenger
Send HomeKit messages with HomeBridge (Pushover / IFTTT / Email)
Stars: ✭ 74 (-50%)
Mutual labels:  mail
imgref
A trivial Rust struct for interchange of pixel buffers with width, height & stride
Stars: ✭ 45 (-69.59%)
Mutual labels:  rust-library
enough mail app
Mail app for iOS, Android and hopefully more platforms in the future. Based on Flutter.
Stars: ✭ 84 (-43.24%)
Mutual labels:  mail
ModMail
A Discord ModMail Bot.
Stars: ✭ 54 (-63.51%)
Mutual labels:  mail
e621 downloader
E621 and E926 downloader made in the Rust programming langauge.
Stars: ✭ 39 (-73.65%)
Mutual labels:  rust-library
go-mail
📧 A cross platform mail driver for GoLang. Featuring Mailgun, Postal, Postmark, SendGrid, SparkPost & SMTP.
Stars: ✭ 169 (+14.19%)
Mutual labels:  mail
Smtp-cracker
[NEW] : Simple Mail Transfer Protocol (SMTP) CHECKER - CRACKER Tool V2
Stars: ✭ 67 (-54.73%)
Mutual labels:  mail
actix-derive
[ARCHIVED] development moved into main actix repo
Stars: ✭ 38 (-74.32%)
Mutual labels:  rust-library
prettysize-rs
Pretty-print file sizes and more
Stars: ✭ 29 (-80.41%)
Mutual labels:  rust-library
rust-ipfs-api
Rust language IPFS API implementation
Stars: ✭ 20 (-86.49%)
Mutual labels:  rust-library
httper
An asynchronous HTTP(S) client built on top of hyper.
Stars: ✭ 16 (-89.19%)
Mutual labels:  rust-library
CYMailDemo
A mail client base on mailcore2
Stars: ✭ 14 (-90.54%)
Mutual labels:  mail
rdp
A library providing FFI access to fast Ramer–Douglas–Peucker and Visvalingam-Whyatt line simplification algorithms
Stars: ✭ 20 (-86.49%)
Mutual labels:  rust-library
Galleon
A badass SMTP mail server built on Node to make your life simpler.
Stars: ✭ 14 (-90.54%)
Mutual labels:  mail
postmark-wordpress
The Official Postmark Wordpress Plugin
Stars: ✭ 17 (-88.51%)
Mutual labels:  mail

mailparse

Build Status Crate

A simple parser for MIME email messages.

API

The primary entry point for this library is the following function:

    parse_mail(&[u8]) -> Result<ParsedMail, MailParseError>

This function takes the raw message data, including headers and body, and returns a structured object to more easily access pieces of the email message. There are other public functions that allow parsing smaller parts of the message as well; refer to the full documentation.

The library is designed to process real-world email data such as might be obtained by using the FETCH command on an IMAP server, or in a Maildir. As such, this library should successfully handle any valid MIME-formatted message, although it may not follow all the strict requirements in the various specifications that cover the format (predominantly IETF RFCs 822, 2045, 2047, 2822, and 5322). As an example, this library accepts raw message data which uses \n (ASCII LF) as line delimiters rather than the RFC-mandated \r\n (ASCII CRLF) line delimiters.

Example usage

    use mailparse::*;
    let parsed = parse_mail(concat!(
            "Subject: This is a test email\n",
            "Content-Type: multipart/alternative; boundary=foobar\n",
            "Date: Sun, 02 Oct 2016 07:06:22 -0700 (PDT)\n",
            "\n",
            "--foobar\n",
            "Content-Type: text/plain; charset=utf-8\n",
            "Content-Transfer-Encoding: quoted-printable\n",
            "\n",
            "This is the plaintext version, in utf-8. Proof by Euro: =E2=82=AC\n",
            "--foobar\n",
            "Content-Type: text/html\n",
            "Content-Transfer-Encoding: base64\n",
            "\n",
            "PGh0bWw+PGJvZHk+VGhpcyBpcyB0aGUgPGI+SFRNTDwvYj4gdmVyc2lvbiwgaW4g \n",
            "dXMtYXNjaWkuIFByb29mIGJ5IEV1cm86ICZldXJvOzwvYm9keT48L2h0bWw+Cg== \n",
            "--foobar--\n",
            "After the final boundary stuff gets ignored.\n").as_bytes())
        .unwrap();
    assert_eq!(parsed.headers.get_first_value("Subject"),
        Some("This is a test email".to_string()));
    assert_eq!(parsed.subparts.len(), 2);
    assert_eq!(parsed.subparts[0].get_body().unwrap(),
        "This is the plaintext version, in utf-8. Proof by Euro: \u{20AC}");
    assert_eq!(parsed.subparts[1].headers[1].get_value(), "base64");
    assert_eq!(parsed.subparts[1].ctype.mimetype, "text/html");
    assert!(parsed.subparts[1].get_body().unwrap().starts_with("<html>"));
    assert_eq!(dateparse(parsed.headers.get_first_value("Date").unwrap().as_str()).unwrap(), 1475417182);

Documentation

See the rustdoc at docs.rs.

Support mailparse

If you want to support development of mailparse, please do so by donating your money, time, and/or energy to fighting climate change. A quick and easy way is to send a donation to Replant.ca Environmental, where every dollar gets a tree planted!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].