1. Products
  2.   Email
  3.   C++
  4.   Mailio
 
  

Open Source C++ Library to Create & Manage Email Messages

Free C++ API for Generating Emails & supports MIME format as well as SMTP, POP3 and IMAP protocols. It allows Email Messages Receiving, Searching, Managing Folders, and More.

What is Mailio?

Mailio is a very powerful C++ library that enables software developers to work with email messages using C++ commands. The library is very easy to handle and can be used on multiple platforms. It is a C++ library for MIME format and fully supports SMTP, POP3, and IMAP protocols. The library supports recognition of different media types, including MIME messages embedded within another message. The MIME message supports the most common headers recognition such as subject, recipients, content type, and more.

The library is very flexible and can be easily used on popular platforms like Linux, MacOS, Microsoft Windows, and more. POP3 is one of the most recent versions of a standard protocol for receiving e-mail. The Mailio has implemented POP3 supports message receiving and removal, getting mailbox statistics with plain and SSL (including START TLS) versions. The library has also implemented IMAP with message receiving, removal and search, getting mailbox statistics, managing folders, and more.

Previous Next

Getting Started with Mailio 

The easiest way to install Mailio is via CMake. From the terminal go into the directory where the library is downloaded, and execute, the following command.

install Mailio via CMake

mkdir build
cd ./build
cmake ..
make install

Create & Send Emails via C++ Library

The Open Source Mailio library allows computer programmers to create and send email messages with just a couple of lines of C++ code. For email sending, you need to create a message object and set its attributes such as author, recipient, subject, and more. Once everything is ready, you need to create an SMTP connection to send the message over it. To receive an email message, the message object can be used to store the received message with just a couple of lines of code. The following example shows how to composing and sending an email inside C++ applications.

How to Compose and Send an Email inside C++ Applications?

#include 

int main() {
    // Initialize SMTP client
    mailio::smtps smtp("smtp.example.com", 587);
    smtp.authenticate("username", "password");

    // Compose email
    mailio::mail_message message;
    message.from("sender@example.com");
    message.to("recipient@example.com");
    message.subject("Test Email");
    message.content("This is a test email sent using Mailio C++ library.");

    // Send email
    smtp.send(message);

    return 0;
}
 

Attach Documents or Images to Emails via C++

The Open Source Mailio library has provided complete functionality for handling email attachments using C++ commands. You can easily select a file or multiple files and attach them to the email message. The library allows users to easily attach popular documents like PDF, Microsoft Word, Excel Images, and many more. You can also easily fetch attachments and store them in the place of your choice on the disk. It is also possible to delete a selected attachment or modify it with a new one. The following example shows how to developers can attach a PDF documents and sending an email messages inside C++ applications.

How to Send Emails with Document Attachments inside C++ Applications?

#include 

int main() {
    // Initialize SMTP client
    mailio::smtps smtp("smtp.example.com", 587);
    smtp.authenticate("username", "password");

    // Compose email with attachment
    mailio::mail_message message;
    message.from("sender@example.com");
    message.to("recipient@example.com");
    message.subject("Test Email with Attachment");
    message.content("Please find the attached document.");

    // Add attachment
    message.attach("path/to/attachment.pdf");

    // Send email
    smtp.send(message);

    return 0;
}
 

Searching Email Messages using C++

The Free Mailio library gives software developers the power to search email messages with just a couple of lines of C++ code. First, you need to provide the correct credentials for connecting with the IMAP server. After that, you can search email messages by providing the message title, message date, sender name, and many more. The library will display all the messages related to your query and will display it as a list, The following example demonstrates how software developers can search email messages inside their C++ applications.

How to Search Email Messages via C++ API?

#include 

int main() {
    // Initialize IMAP client
    mailio::imaps imap("imap.example.com", 993);
    imap.authenticate("username", "password");

    // Search for emails
    auto messages = imap.search("FROM sender@example.com SUBJECT 'Test'");
    
    // Process search results
    for (auto& message : messages) {
        // Print email details
        std::cout << "From: " << message.from() << std::endl;
        std::cout << "Subject: " << message.subject() << std::endl;
        std::cout << "Content: " << message.content() << std::endl;
    }

    return 0;
}
 
 English