⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 email.hpp

📁 经典的string 函数库学习资料
💻 HPP
字号:
/** * @file email.hpp * @brief 电子邮件包装,函数的声明 * @author 泥偶 * @since  2003-08-29 * @date   2003-09-23 */#ifndef EMAIL_HPP#define EMAIL_HPPextern "C"{    #include <sys/types.h>}#include "xstring.hpp"namespace x{    /**     * @class Email email.hpp "email.hpp"     * @brief 发送电子邮件包装     * @version 0.99pre2     */    class Email    {    public:        /// @brief 设置收件人地址        bool setTo(const xstring& inAddress);        /// @brief 设置抄送地址        bool setCc(const xstring& inAddress);        /// @brief 设置秘件抄送地址        bool setBcc(const xstring& inAddress);        /// @brief 设置发件人地址        bool setFrom(const xstring& inAddress);        /// @brief 设置邮件主题        bool setSubject(const xstring& inSubject);        /// @brief 设置文本格式的邮件内容        bool setText(const xstring& inText);        /// @brief 设置HTML格式的邮件内容        bool setHTML(const xstring& inHTML);        /// @brief 设置邮件的附件        bool addAttachment(            const xstring& inMessage,            const xstring& inName           = "",            const xstring& inContentType    = "application/octet-stream"        );        /// @brief 设置邮件的附件        bool addAttachmentFile(const xstring& inFileName);        /// @brief 发送邮件        bool send(void);//============================================================================    private:        /// @brief 判断附件的类型        static xstring getContentType(const xstring& inFilename);        /// @struct Attachment        /// @brief 电子邮件附件        struct Attachment        {            xstring ctype;      ///< MIME类型            xstring message;    ///< 附件内容            xstring encode;     ///< 编码方式            xstring name;       ///< 附件名字        };        /// @brief Build message parts of an multipart mail        static xstring buildMessage(const Attachment& inAttachment);        /// @brief Build a multipart mail        xstring buildMultipart(void);        /// @brief 调用sendmail发送邮件        static bool mail(            const xstring& to,            const xstring& subject,            const xstring& message,            const xstring& additional_headers   = ""        );        /// @brief 向文件描述符写入字符串,保证写完        static ssize_t writen(int d, const xstring& str);        /// @brief 向文件描述符写入字符,保证写入指定的字节数        static ssize_t writen(int d, const void* buf, size_t nbytes);    private:        xstring mailTo;         ///< 收件人        xstring mailCc;         ///< 抄送        xstring mailBcc;        ///< 秘件抄送        xstring mailFrom;       ///< 发件人        xstring mailSubject;    ///< 主题        xstring mailText;       ///< 文本格式的信件主体        xstring mailHTML;       ///< HTML格式的信件主体        std::vector<Attachment> mailAttachments;    ///< 附件    };  // class Email}   // namespace x#endif  // ifndef EMAIL_HPP

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -