VMime: C++ Mail Library

Tag - messaging

Entries feed - Comments feed

Thursday, Aug 5 2010

Connection time out

By popular demand, it is now possible to handle time out during connection to IMAP, POP3 and SMTP servers.

There is nothing to change in your code to enjoy this new feature, at least if you already set a time out handler on the store (vmime::net::store::setTimeoutHandler). The same time out handler is used for connection and for data exchange after the connection has been opened.

Please note: for now, this is only available in VMime SVN, revision 559, and for POSIX platforms (this feature is not yet supported on Windows).

Tuesday, May 18 2010

New feature: get parsed message from store

Hi VMime users!

Let's focus today on a new feature in VMime 0.9. Until now, when you wanted to "explore" the contents of a vmime::net::message (that is, a message hosted on a IMAP or a POP3 store), you had to extract it entirely, or to use low-level fetch() and extract() functions on the message object.

Since the current development release of May 18th, there is a new helper function that will let you access the remote message like a "normal" vmime::message, and actually download the message data only when it is required (this only works for IMAP).

   // Connect to the IMAP store
vmime::ref <vmime::net::session> sess = vmime::create <vmime::net::session>();

   vmime::utility::url storeURL("imap://username:password@imap.example.com");

vmime::ref <vmime::net::store> store = sess->getStore(storeURL);
   store->connect();

// Open the INBOX
   vmime::ref <vmime::net::folder> folder = store->getDefaultFolder();
   folder->open(vmime::net::folder::MODE_READ_WRITE);

// Get the first message in the INBOX
vmime::ref <vmime::net::message> msg = f->getMessage(1);

// Construct the parsed message (a few data, header and structure,
// is actually downloaded from the IMAP server)
   vmime::ref <vmime::message> parsedMsg = msg->getParsedMessage();

// Here, extract() will actually download message data from the server

vmime::utility::outputStreamAdapter out(std::cout);
parsedMsg->getBody()->extract(out);

That's all folks! Update your source tree to the latest SVN head to enjoy this new feature.

Saturday, Apr 10 2010

Connecting to GMail SMTP

Some users fequently ask me how to connect to GMail SMTP service with VMime. You have to connect to server using SMTP protocol (not SMTPS), and set the connection.tls property to true to initiate a secured connection using STARTTLS.

The following code is known to work:

vmime::utility::url url("smtp://smtp.gmail.com");
vmime::ref tr = session->getTransport(url);
tr->setProperty("connection.tls", true);
tr->setProperty("auth.username", "gmail-login");
tr->setProperty("auth.password", "gmail-password");
tr->setProperty("options.need-authentication", true);
tr->setCertificateVerifier(yourCertificateVerifier);

Thursday, Apr 17 2008

Messages actually not deleted from a folder

Q: I called deleteMessage() to delete a message from a store, but the message is not actually deleted!

A: Call folder->close(true) to expunge messages marked as deleted.

Current Version

0.9.0 (2008/10/19)

Download
ChangeLog