MailMessage.qm.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
// @file MailMessage.qm MailMessage module definition
/* MailMessage.qm Copyright 2012 - 2017 Qore Technologies, s.r.o.
Original Authors: 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
// assume local var scope, do not use "$" for vars, members, and method calls
// require type declarations everywhere
// disallows access to backwards-compatible "noop" variants
// enables all warnings
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<string> to(); // list of names for to (header only) will be prefilled (and overwritten) with the recipients
list<string> cc(); // list of cc's
list<string> bcc(); // list of bcc's
// message data itself
*data body;
// message body content transfer encoding
string bodyEncoding = EncDefault;
// message body content type
*string bodyContentType;
// list of Attachments
list<Attachment> attachments();
// list of Parts that are not Attachments (and not the main Message body - could be alternative representations of the body, for example)
list<Part> parts();
string sender;
public:
public :
string mpboundary = replace(make_base64_string(string(now_us())), "=", "");
public:
constructor(string n_sender, string n_subject);
constructor(string msg);
string serialize();
private:
processPart(hash p);
public:
static *string getEmailAddress(string str);
static bool checkEmailAddress(string str);
list<string> addTO(string recipient);
list<string> addCC(string recipient);
list<string> addBCC(string recipient);
*string getSender();
*string getFrom();
list<string> getTO();
list<string> getCC();
list<string> getBCC();
string getSubject();
list<string> getRecipients();
bool sendPossible();
checkSendPossible();
setBody(data n_body, string n_enc = EncDefault, *string n_content_type);
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<Attachment> getAttachments();
list<Part> 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 include_body = False);
string toLine();
static string checkEncoding(data data, string enc, bool noneok = False);
static string encodeTransferData(data data, string enc, reference<hash> hdr);
static string encodeData(data data, string mime, string disp, string enc);
static string getLine(reference<string> msg, reference<int> pos);
private:
list<string> 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 filename, string mimetype, data filedata, string encoding = 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) ;
};
};
MailMessage::Message::parseHeader
static hash parseHeader(string hdr, bool decode=True)
parses the given string representing a header line and returns a single key - value hash for the head...
MailMessage::Message::addBody
addBody(string str)
concatenates a string to the message body
MailMessage::Message::getHeaderString
string getHeaderString(string eol="\", bool encode=True)
returns a string of the message headers
MailMessage::Message::getAttachments
list< Attachment > getAttachments()
returns a list of Attachment objects for the Message
MailMessage::Message::addHeader
addHeader(string hdr)
adds a header to the Message
MailMessage::Part
class representing a MIME part of a Message
Definition: MailMessage.qm.dox.h:594
MailMessage::Encodings
const Encodings
a list of all known content encoding schemes encodings
Definition: MailMessage.qm.dox.h:126
MailMessage::Message::encodeTransferData
static string encodeTransferData(data data, string enc, reference< hash > hdr)
returns a string of message data according to the encoding passed
now_us
date now_us()
MailMessage::Message::getSender
*string getSender()
returns the sender&#39;s address in display format
MailMessage::Message::toLine
string toLine()
returns a single line string summarizing the Message
MailMessage::Message
The Message class holds the information for a single email Message.
Definition: MailMessage.qm.dox.h:172
make_base64_string
string make_base64_string(string str, softint maxlinelen=-1)
MailMessage::Message::getEmailAddress
static *string getEmailAddress(string str)
fetch the email address out of a sender/rcpt string
MailMessage::Message::getHeader
softlist getHeader()
returns the current Message headers as a list of strings
True
const True
MailMessage::Message::getSubject
string getSubject()
returns the subject of the Message
MailMessage::Message::getTO
list< string > getTO()
returns the list of "To:" addresses
MailMessage::Message::sendPossible
bool sendPossible()
returns True if the message can be sent, False if not
binary
binary binary()
MailMessage::Message::doHeaderValue
static string doHeaderValue(string hdr, string val, string eol="\", bool encode=True)
encodes a header value according to the parameters
MailMessage::Message::getCC
list< string > getCC()
returns the list of "CC:" addresses
MailMessage::Message::addBCC
list< string > addBCC(string recipient)
add a recipient to the Message&#39;s bcc list
ContentTransEncBase64
const ContentTransEncBase64
MailMessage::Message::attach
attach(string name, string mime, data att, string enc=EncDefault, *hash hdr)
creates an attachment for the Message
False
const False
replace
string replace(string str, string source, string target, int start=0, int end=-1)
list
list list(...)
MailMessage::Message::getHeaders
*hash getHeaders()
returns the current Message headers as a hash
MailMessage::EncQuotedPrintable
const EncQuotedPrintable
"quoted-printable" content transfer encoding
Definition: MailMessage.qm.dox.h:123
MailMessage::Message::important
bool important()
returns the current importance setting
MailMessage::Attachment
class representing a MIME Attachment for the Message
Definition: MailMessage.qm.dox.h:660
MailMessage::Message::getBody
*data getBody()
returns the Message body
MailMessage::Message::getParts
list< Part > getParts()
returns a list of non-attachment Part objects for the Message
MailMessage::Message::constructor
constructor(string n_sender, string n_subject)
creates a Message object from the arguments given; this variant of the constructor is designed to be ...
MailMessage::Message::receiptRead
bool receiptRead()
returns the current read delivery receipt setting
MailMessage::Message::mpboundary
string mpboundary
create a different multipart boundary string every time based on the current time ...
Definition: MailMessage.qm.dox.h:216
MailMessage::Message::checkEncoding
static string checkEncoding(data data, string enc, bool noneok=False)
checks the data against the encoding and returns the new encoding (if the encoding is EncDefault for ...
MailMessage::Message::serialize
string serialize()
serializes the message to a string that can be sent to an SMTP server, for example ...
MailMessage::EncBase64
const EncBase64
base-64 content transfer encoding
Definition: MailMessage.qm.dox.h:120
MailMessage::Message::getBodyTransferEncoding
string getBodyTransferEncoding()
returns the transfer encoding for the mssage body (see Message Encodings for possible values) ...
MailMessage::Message::getRecipients
list< string > getRecipients()
return all the email addresses the message will be sent to, a combination of the "To:", "CC:", and "BCC:" lists
ContentTransEncQuotedPrintable
const ContentTransEncQuotedPrintable
MailMessage::Message::getLine
static string getLine(reference< string > msg, reference< int > pos)
returns the first "\r\n" terminated line from the argument, updates the byte position argument ...
MailMessage::Message::setHeader
setHeader(string hdr)
sets/replaces the Message headers
MailMessage::Message::setBody
setBody(data n_body, string n_enc=EncDefault, *string n_content_type)
sets or replaces the Message body
MailMessage::EncNone
const EncNone
no content transfer encoding (not recommended as SMTP servers break up long lines automatically) ...
Definition: MailMessage.qm.dox.h:117
MailMessage::Message::encodeData
static string encodeData(data data, string mime, string disp, string enc)
returns a string of message data according to the encoding passed
MailMessage::Message::getBCC
list< string > getBCC()
returns the list of "BCC:" addresses
MailMessage::Message::checkEmailAddress
static bool checkEmailAddress(string str)
returns True if the string contains an email address, False if not
MailMessage::Message::getFrom
*string getFrom()
returns the sender&#39;s email address
MailMessage::Message::receiptDelivery
bool receiptDelivery()
returns the delivery receipt setting
MailMessage
the MailMessage namespace holds all public definitions in the MailMessage module
Definition: MailMessage.qm.dox.h:105
hash
hash hash(object obj)
MailMessage::Message::checkSendPossible
checkSendPossible()
throws a MESSAGE-ERROR exception if the Message cannot be sent
MailMessage::Message::addCC
list< string > addCC(string recipient)
add a recipient to the Message&#39;s cc list
MailMessage::Message::addTO
list< string > addTO(string recipient)
add a recipient to the Message&#39;s recipient list
MailMessage::EncDefault
const EncDefault
default content transfer encoding depending on attachment type
Definition: MailMessage.qm.dox.h:114
MailMessage::Message::toString
string toString(bool include_body=False)
returns a multi-line string representing the Message