Home

Awesome

GMime.jl

Stable Dev Build Status Coverage Registry

GMime is a convenient wrapper around the GMime library for parsing email messages in Julia. It can extract sender, recipient, date, body text, attachments and other email information.

Installation

To install GMime, simply use the Julia package manager:

] add Gmime

Usage

Here's a small example of how to parse content from an email body:

using GMime
using EasyCurl

# Fetch the email data from an IMAP server
response = imap_request(
    "imaps://imap.gmail.com:993",
    get(ENV, "IMAP_USER", ""),
    get(ENV, "IMAP_PASSWORD", ""),
    mailbox = "INBOX",
    path = "MAILINDEX=993"
)

# Extract the raw email body
data = imap_body(response)

# Parse the email using GMime
julia> email = parse_email(data)
šŸ“§ Email:
   šŸ“¤ From: Broker Support <support@broker.com>
   šŸ“„ To: Portfolio Manager <pm@hedgefund.com>
   šŸ•’ Date: 2024-08-06T17:34:04
   šŸ“Ž Attachments:
      1. šŸ“Ž Attachment:
   šŸ“„ Name: CashFlowReport_Q3_2024.pdf
   šŸ› ļø Encoding: base64
   šŸ· Mime type: application/pdf
   šŸ“ Size: 18000 bytes

      2. šŸ“Ž Attachment:
   šŸ“„ Name: ClosedPositions_Summary_2024-08-06.csv
   šŸ› ļø Encoding: base64
   šŸ· Mime type: text/csv
   šŸ“ Size: 250000 bytes

      3. šŸ“Ž Attachment:
   šŸ“„ Name: DailyTransaction_2024-08-06.csv
   šŸ› ļø Encoding: base64
   šŸ· Mime type: text/csv
   šŸ“ Size: 12800 bytes

Useful Links

  1. Turn on the IMAP support at email provider cabinet. See this Gmail guide.
  2. Create an app-specific password for your email. See here for details.

Contributing

Contributions to GMime are welcome! If you encounter a bug, have a feature request, or would like to contribute code, please open an issue or a pull request on GitHub.