Logo
  • Main Page
  • Related Pages
  • Modules
  • Classes
  • Files

mmsmail.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2007 Stefan Schwarzer, Jens Schneider,             *
00003  *                           Matthias Hardt, Guido Madaus                  *
00004  *                                                                         *
00005  *   Copyright (C) 2007-2008 BerLinux Solutions GbR                        *
00006  *                           Stefan Schwarzer & Guido Madaus               *
00007  *                                                                         *
00008  *   Copyright (C) 2009-2013 BerLinux Solutions GmbH                       *
00009  *                                                                         *
00010  *   Authors:                                                              *
00011  *      Stefan Schwarzer   <stefan.schwarzer@diskohq.org>,                 *
00012  *      Matthias Hardt     <matthias.hardt@diskohq.org>,                   *
00013  *      Jens Schneider     <jens.schneider@diskohq.org>,                   *
00014  *      Guido Madaus       <guido.madaus@diskohq.org>,                     *
00015  *      Patrick Helterhoff <patrick.helterhoff@diskohq.org>,               *
00016  *      René Bählkow       <rene.baehlkow@diskohq.org>                     *
00017  *                                                                         *
00018  *   This library is free software; you can redistribute it and/or         *
00019  *   modify it under the terms of the GNU Lesser General Public            *
00020  *   License version 2.1 as published by the Free Software Foundation.     *
00021  *                                                                         *
00022  *   This library is distributed in the hope that it will be useful,       *
00023  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00024  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00025  *   Lesser General Public License for more details.                       *
00026  *                                                                         *
00027  *   You should have received a copy of the GNU Lesser General Public      *
00028  *   License along with this library; if not, write to the                 *
00029  *   Free Software Foundation, Inc.,                                       *
00030  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
00031  **************************************************************************/
00032 
00033 #ifndef MMSMAIL_H_
00034 #define MMSMAIL_H_
00035 #ifdef __HAVE_VMIME__
00036 #include "mmstools/base.h"
00037 #include "mmstools/mmserror.h"
00038 #include <vmime/vmime.hpp>
00039 #include <vmime/platforms/posix/posixHandler.hpp>
00040 #include <vector>
00041 
00042 /**
00043  *  A smtp mail transfer class.
00044  *
00045  *  This class provides functions to to send e-mails via a smtp server.
00046  *  Secure connections are note supported.
00047  *
00048  *  @author Patrick Helterhoff
00049  */
00050 class MMSMail {
00051 private:
00052     std::string                         subject;
00053     std::string                         returnAddress;
00054     std::vector<std::string>            recipients;
00055     std::string                         mailBody;
00056     std::string                         host;
00057     vmime::ref<vmime::net::transport>   transportService;
00058 
00059 public:
00060     /**
00061      * Constructor of class MMSMail.
00062      *
00063      * @param _subject       [in] the mail subject line
00064      * @param _returnAddress [in] the return address
00065      * @param _host          [in] the smtp server name
00066      */
00067     MMSMail(const std::string _subject, const std::string _returnAddress, const std::string _host);
00068 
00069     /** Destructor of class MMSMail. */
00070     ~MMSMail();
00071 
00072     /**
00073      * Returns the mail subject line.
00074      */
00075     std::string getSubject() const;
00076 
00077     /**
00078      * Sets the mail subject line.
00079      *
00080      * @param subject [in] the mail subject
00081      */
00082     void setSubject(const std::string subject);
00083 
00084     /**
00085      * Returns the mails return addresss.
00086      */
00087     std::string getReturnAddress() const;
00088     /**
00089      * Sets the mails return address.
00090      *
00091      * @param returnAddress [in] the mails return address
00092      */
00093     void setReturnAddress(std::string returnAddress);
00094 
00095     /**
00096      * Returns the recipient at the given index.
00097      *
00098      * @param index [in] index of the recipient (first element = 0)
00099      */
00100     std::string getRecipient(int index) const;
00101 
00102     /**
00103      * Returns the current number of recipients.
00104      */
00105     const int getRecipientCount() const;
00106 
00107     /**
00108      * Adds a recipient to the current mail.
00109      */
00110     void addRecipient(std::string recipient);
00111 
00112     /**
00113      * Removes a recipient at the given index.
00114      *
00115      * @param index [in] index of the recipient (first element = 0)
00116      */
00117     void removeRecipient(int index);
00118 
00119     /**
00120      * Returns the mails message text.
00121      */
00122     std::string getMailBody() const;
00123 
00124     /**
00125      * Sets the mails message text.
00126      *
00127      * @param mailBody [in] Message text of the mail
00128      */
00129     void setMailBody(std::string mailBody);
00130 
00131     /**
00132      * Returns the current mail servers address.
00133      */
00134     std::string getHost() const;
00135 
00136     /**
00137      * Sets the mail servers address.
00138      *
00139      * @param host [in] the mail servers address
00140      */
00141     void setHost(std::string host);
00142 
00143     /**
00144      * Use this to set user and password for the smtp server connection, if necessary.
00145      *
00146      * @param   user        [in] the ftp user
00147      * @param   password    [in] the password
00148      */
00149     void setAuthData(const std::string &user, const std::string &password);
00150 
00151     /**
00152      * Sends the mail to the specified recipients.
00153      *
00154      * @throws MMSError if errors occure during the mail send.
00155      */
00156     void send();
00157 };
00158 
00159 #endif
00160 #endif /* MMSMAIL_H_ */

Generated by doxygen