void sendMessage(string fromstr, string tostr, string subjectstr, string contentstr, string urlString) { try { vmime::utility::url url(urlString); vmime::ref <vmime::net::transport> tr = g_session->getTransport(url); // Enable TLS support if available tr->setProperty("connection.tls", true); tr->setCertificateVerifier(vmime::create <NonInteractiveCertificateVerifier>()); vmime::mailbox from(fromstr); vmime::mailboxList to; to.appendMailbox(vmime::create <vmime::mailbox>(tostr)); std::ostringstream data; data << "From: " << fromstr << "\r\nTo: " << tostr << "\r\nSubject: " << subjectstr << "\r\n" << contentstr << "\r\n"; // Connect to server tr->connect(); vmime::string msgData = data.str(); vmime::utility::inputStreamStringAdapter vis(msgData); tr->send(from, to, vis, msgData.length()); tr->disconnect(); } catch (vmime::exception& e) { } catch (std::exception& e) { } }