All Classes Namespaces Functions Variables Groups Pages
MailMessage.qm.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
// @file MailMessage.qm MailMessage module definition
/* MailMessage.qm Copyright 2012 Wolfgang Ritzinger, Marian Bonda, Pavol Potoncok
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
// minimum qore version
// need mime definitions
/* Version History
* 2012-11-02 v1.0.4: David Nichols <david@qore.org>
+ minor doc corrections and non-functional code changes
* 2012-11-02 v1.0.3: David Nichols <david@qore.org>
+ requires Mime module 1.3 for the MultiPartMessage::parseBody() method
+ fixed a bug where the part/attachment content-type was set to the content-type of the message
+ try to get the filename of attachments from the content-type header if not set in the content-disposition header
+ message parts that themselves have parts are now supported
+ fixed recognizing mime messages with additional text after the version number (ex: "Mime-Version: 1.0 (Mac OS X Mail 6.2 \(1499\))")
* 2012-09-17 v1.0.2: David Nichols <david@qore.org>
+ use <string>::isPrintableAscii() to determine which mail headers need encoding
* 2012-09-17 v1.0.1: David Nichols <david@qore.org>
+ fixed a bug encoding mail headers where mail headers requiring encoding were not encoded and those not requiring encoding were encoded with Q encoding
* 2012-06-14 v1.0: David Nichols <david@qore.org>
+ moved from the SmtpClient module to an independent module to also support the Pop3Client class
*/
namespace MailMessage {
const EncDefault = "default";
const EncNone = "none";
const EncBase64 = ContentTransEncBase64;
const EncQuotedPrintable = ContentTransEncQuotedPrintable;
const Encodings = (
EncDefault,
EncNone,
EncBase64,
EncQuotedPrintable,
);
class Message {
public:
private :
// the sender
string from;
// subject is a header field
string subject;
// additional headers
hash headers; // hash of additional headers except the ones below
// message statuses
bool importance = False;
bool deliveryReceipt = False;
bool readReceipt = False;
// names
list to = (); // list of names for to (header only) will be prefilled (and overwritten) with the recipients
list cc = (); // list of cc's
list bcc = (); // list of bcc's
// message data itself
*data body;
// message body content transfer encoding
string bodyEncoding = EncDefault;
// list of Attachments
list attachments = ();
// list of Parts that are not Attachments (and not the main Message body - could be alternative representations of the body, for example)
list parts = ();
string sender;
public:
private:
public:
constructor(string sender, string subject);
constructor(string msg);
private:
processPart(hash p);
public:
static *string getEmailAddress(string str);
static bool checkEmailAddress(string str);
list addTO(string recipient);
list addCC(string recipient);
list addBCC(string recipient);
*string getSender();
*string getFrom();
list getTO();
list getCC();
list getBCC();
string getSubject();
list getRecipients();
bool sendPossible();
checkSendPossible();
setBody(data body, string enc = EncDefault);
addBody(string str);
addBody(binary bin);
*data getBody();
string getBodyTransferEncoding();
static hash parseHeader(string hdr, bool decode = True);
setHeader(string hdr);
setHeader(list hdrs);
setHeader(hash hdrs);
addHeader(string hdr);
addHeader(list hdrs);
addHeader(hash hdrs);
softlist getHeader();
*hash getHeaders();
bool important();
important(softbool i);
bool receiptRead();
receiptRead(bool arg);
bool receiptDelivery();
receiptDelivery(bool arg);
attach(string name, string mime, data att, string enc = EncDefault, *hash hdr);
attach(Attachment att);
list getAttachments();
list getParts();
static string doHeaderValue(string hdr, string val, string eol = "\r\n", bool encode = True);
string getHeaderString(string eol = "\r\n", bool encode = True);
string toString(bool body = False);
string toLine();
static string checkEncoding(data data, string enc, bool noneok = False);
static string encodeTransferData(data data, string enc, reference hdr);
static string encodeData(data data, string mime, string disp, string enc);
static string getLine(reference msg, reference pos);
private:
list getEnvelopeList();
public:
};
class Part {
public:
// no public members
private:
public:
private :
string name;
string mime;
data data;
string enc;
// any extra headers for the message
*hash headers;
public:
// will only be called internally when parsing a Message
constructor(string name, string mime, data data, string enc = EncDefault, *hash hdr);
string getName();
string getMime();
data getData();
string getTransferEncoding();
*hash getHeaders();
add(MultiPartMixedMessage mpm);
};
class Attachment : public Part {
public:
// no public members
private:
public:
constructor(string name, string mime, data data, string enc = EncDefault, *hash hdr);
};
};