diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2015-04-29 18:58:07 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2015-04-29 18:58:07 +0200 |
commit | cb69299b9d59db0888e942025ae4915c6f32d066 (patch) | |
tree | fcb85301442a9eda1ed9d60a8ba52d8c60f11114 /src/mail.cpp | |
parent | fa132310bf61c115907e5c237333207f308b1de4 (diff) | |
download | aCms-cb69299b9d59db0888e942025ae4915c6f32d066.tar.gz aCms-cb69299b9d59db0888e942025ae4915c6f32d066.tar.bz2 |
added libquickmail and email registration
Diffstat (limited to 'src/mail.cpp')
-rw-r--r-- | src/mail.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/mail.cpp b/src/mail.cpp new file mode 100644 index 0000000..84e1210 --- /dev/null +++ b/src/mail.cpp @@ -0,0 +1,39 @@ +#include "mail.hpp" + +#include <iostream> + +mailer::mailer( std::string server, unsigned short port, std::string username, std::string password, std::string from ) + : server( server ), port( port ), username( username ), password( password ), from( from ) +{ + quickmail_initialize( ); + mailobj = quickmail_create( NULL, NULL ); +} + +mailer::~mailer( ) +{ + quickmail_destroy( mailobj ); +} + +void mailer::send( ) +{ + if( !from.empty( ) ) { + quickmail_set_from( mailobj, from.c_str( ) ); + } + + if( !to.empty( ) ) { + quickmail_add_to( mailobj, to.c_str( ) ); + } + + if( !subject.empty( ) ) { + quickmail_set_subject( mailobj, subject.c_str( ) ); + } + + if( !body.empty( ) ) { + quickmail_add_body_memory( mailobj, "plain/text", const_cast<char *>( body.c_str( ) ), body.size( ), 0 ); + } + + const char *errmsg; + errmsg = quickmail_send( mailobj, server.c_str( ), port, username.c_str( ), password.c_str( ) ); + std::cerr << "ERROR: " << errmsg << std::endl; +} + |