Connecting to GMail SMTP/IMAP

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://");
vmime::ref <vmime::net::transport> 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);

To connect to IMAP on GMail, use the following code:

vmime::utility::url url("imaps://");
vmime::ref <vmime::net::store> store = session->getStore(url);

Major bug fixes

Hello VMime users!

Thanks to László Vadócz, a possible segfault in stringUtils::countASCIIchars() has been fixed. A patch is available.

There was another major issue with body contents not generating when using streamContentHandler: EOF condition was not reset correctly when stream::reset() was called. The patch is available here.

GPL v3 and dual-licensing

Hi all!

VMime has been relicensed under the GNU General Public License version 3. So, this will be the default license starting from version 0.9.1 (which is currently in development).

Additionally, due to a lot of demand, and to support development, VMime is now available under dual-licensing:

  • GNU GPL v3 for Free and Open Source projects. This is the default license for VMime.
  • Commercial license, for proprietary software. This license is available for purchase.

Please consult Licensing Overview and Dual-Licensing Model for more information about this.

New website

The new website for VMime is now online!

Oh… and for those wondering if VMime is still maintained: YES, it is! In the last year, I had not much time to make releases but I worked on it from time to time (mainly bug fixes, no new features). Since I have a little more time now, I will try to post news here regularly.

Please note I am still looking for contributors as there is a lot of work to do, so please feel free to contact me if you are interested!

Build against libgnutls >= 2.8

VMime 0.9.0 autoconf build process uses the libgnutls-config script to search for GNU TLS (by using AM_PATH_LIBGNUTLS). This script is deprecated and not shipped in gnutls 2.8.0 and later; pkg-config should now be used. Andreas Metzler provided a patch for fixing this.

Version 0.9.0 released

Hello all!

Version 0.9.0 is (finally) out, with some refactoring, API changes and bug fixes. This is an excerpt from the ChangeLog :

  • File Attachments: fixed constructor ambiguity due to implicit conversions. Removed default values and reordered parameters (API breaking change). Many thanks to Philipp Frenkel. More information here.
  • Text/Words: fixed incorrect white-space between words.
  • IMAP: fixed bug in modified UTF-7 encoding.
  • Implemented thread-safe reference counting for smart pointers, whenever possible (GCC built-in functions / pthread / Win32).
  • SMTP: better parsing of ESMTP extensions.
  • Maildir: added support for “Courier” Maildir.

Is VMime thread-safe?

VMime is thread-safe in the sense you can have multiple threads running VMime code at the same time.

What you may NOT do is to share VMime objects (for writing) between threads. For example, you should NOT modify the same bodyPart object from two threads at the same time (reading is OK) unless you write your own synchronization mechanism between the calls.

If you are using the messaging module, it is OK to access multiple mailboxes (store objects) from multiple threads (each thread accesses one mailbox).

The rest of the code (parser, utils, etc.) is thread-safe as long as (again…) you don’t share the objects (body parts, mailboxes, etc.) between multiple threads.

There are some singleton objects in VMime. There is absolutely no problem when instanciating a VMime singleton for the first time within multi-threaded code. Instanciation of all singletons is forced when VMime is initialized (static code, executed before your main()).

Version 0.8.1 released

Version 0.8.1 is released: a lot of bugs fixed.

  • Imbue classic “C” locale for the output of message parts and protocol commands (thanks to Mörtsell Anders).
  • Renamed ‘vmime::platformDependant’ to ‘vmime::platform’. The old name has been kept for compatibility with previous versions.
  • SMTP: reissue EHLO command after a successful STARTTLS negociation.
  • Word Encoder: fixed bug #1096610 which caused encoding of a non-integral number of characters (and then, generation of incorrectly-formed words) with multi-bytes charsets.
  • Fixed bugs in MHTML code: ‘CID’ prefix should not be case-sensitive; fixed detection of parts identified by a ‘Content-Location’.
  • IMAP and Maildir: added vmime::net::folder::destroy() to delete folders.
  • Renamed ‘byte’ to ‘byte_t’ to fix compilation problems on Fedora core 5 (thanks to Rafael Fernandez).
  • IMAP: added a “relaxed” mode to IMAP parser to allow 8-bit characters where not allowed by the standard (thanks to Tim Teulings for having found the bug).
  • Added service::isSecuredConnection() and service::getConnectionInfos() to retrieve information about the connection.
  • Added support for attachments of type “message/rfc822”.
  • IMAP: implemented multi-fetching. Now using “FETCH x:y” instead of sending (y-x+1) “FETCH” requests.
  • POSIX sockets: use getaddrinfo() if available. This should bring thread-safe DNS resolution and IPv6 support.
  • IMAP: compatibility bugs + enhanced debugging trace.
  • Exception: fixed segfault in destructor when destroying an exception chain with more than 2 elements (thanks to Bertrand Benoit).
  • POSIX: fixed a bug in argument vector; last argument was not NULL (thanks to Bertrand Benoit).
  • Maildir: fixed problem with ‘:’ in filename on Windows platform (thanks to Benjamin Biron).
  • Utility: fixed buffer overrun in random::getString (thanks to Benjamin Biron).
  • SMTP: fixed bug in disconnect() when authentication is not needed (thanks to Benjamin Biron).
  • Utility: gmtime() and localtime() are reentrant when using MS C runtime library (MinGW/MSVC).