Info : to send the created email, use the smtp class!
Create a mail from "user@example.com" to "user2@example.com", containing two parts : a textual part with "Content of text part" and a HTML part with "Content of HTML part". There is also added an attachment (here a textual file).
$mail = new Domframework\Mail ();
$mail->setFrom ("user@example.com", "User Example");
$mail->addTo ("user2@example.com", "User2 Example");
$mail->setBodyText ("Content of text part");
$mail->setBodyhtml ("Content of HTML part");
$mail->addAttachment ("file1.text", "File1 content");
echo $mail->getMail ();
The library allow too to manage the inline images :
$mail = new Domframework\Mail ();
$contentID = $mail->addAttachmentInline ("file2", "Content of INLINE file");
$mail->setBodyhtml ("Content of HTML part <img src='cid:$contentID'/>");
echo $mail->getMail ();
The library can read existing mails :
$mail = new Domframework\Mail ();
$mail->readMail (file_get_contents ("MAILFILE.eml"));
$mail->getDetails ();
You can get the details of the mails with :
$mail = new Domframework\Mail ();
$mail->readMail (file_get_contents ("MAILFILE.eml"));
$mail->getDetails ();
This will produce an array with a lot of informations.
To get the attachment of the mail :
$mail = new Domframework\Mail ();
$mail->readMail (file_get_contents ("MAILFILE.eml"));
$binaryAttachment = $mail->getAttachment (0);Namespace Domframework
/** The class to create a complete email. Can read an email from a content
No property available
/** The constuctor verify if the external libraries are available
/** Add an attachment to the mail. The allowed encodings are "quoted-printable" or "base64"@param string $nameThe name of the file@param string $fileContentThe content of the file in binary@param string|null $encodingThe output encoding. Can be base64/quoted-printable@param boolean|null $inlineStore the file in inline mode (multipart/related) If false, store the file in attached mode (multipart/mixed)
/** Add an inline attachment to the mail. The allowed encodings are "quoted-printable" or "base64" Return the Content-ID needed to be used in HTML page like : <img src='cid:XXXXXXXXXX'/>@param string $nameThe name of the file@param string $fileContentThe content of the file in binary@param string|null $encodingThe output encoding. Can be base64/quoted-printable@returnstring The content ID created
/** Add a generic header@param string $headerThe name of the Header (without colon)@param string $valueThe value the store. The format must be correct !@param string|null $sectionIDThe section to modify. If null, use the main
/** Add a To: header. If it already exists, add a new recipient@param string $toMailThe mail to add@param string|null $toNameThe name of the recipient
/** Analyze the Content-Type line and return an array with the values@param string $contentTypeThe content Type to analyze@returnarray The analyzed Content-Type
/**
Convert a From/To string to array. Manage multiple recipients
Ex. : toto toto <toto@toto.com>, titi <titi@titi.com>
array (array ("name"=>"toto toto", "mail"=>"toto@toto.com"),
array ("name"=>"titi", "mail"=>"titi@titi.com"))
@param string $data The From/To field content
@return array The array with the converted data
/** Create the complete mail structure
/** Delete a specific header@param string $headerThe header to remove@param string|null $sectionIDThe section to modify. If null, use the main
/** Get an attachment of the mail@param integer $numberthe number of attach to get starting to 0@param boolean|null $inlineReturn only the attachments Inline if true@returnstring the content of the attachment. Can be binary
/** Get the attachment details@param integer $numberthe number of attach to get starting to 0@param boolean|null $inlineReturn only the attachments Inline if true@returnarray containing the information of the attachment
/**
Return the HTML body if exists in UTF-8. If the body is not in UTF-8, it
is converted
Return false if it doesn't exists
@return string|false The HTML body converted in UTF-8 or false if there is
no HTML part in the mail
/**
Get the text body if exists in UTF-8. If the body is not in UTF-8, it is
converted
Return false if it doesn't exists
@return string|false The Text body converted in UTF-8 or false if there is
no Text part in the mail
/**
Get the Date header if defined.
Return false if not defined
@return string|bool The date Header if defined or false if not defined
/**
Return the Date header (if defined) in timestamp
Return false if not defined
@return integer|bool The date Header if defined or false if not defined
/**
Return an array with the details of the mail :
the number of attachments, the from, to, subject in UTF-8, if there is
a text and/or html body
@return array The details of the mail
/**
Return the From header as it is written in the mail
@return string The From Header defined in the mail
/**
Return the From header converted to array with mail and name keys
@return array The From details
/** Get a generic header If there is multiple headers with the same name, return the first@param string $headerThe header to get@param array|null $headersOptional headers to examine@returnstring|bool the literal value or false if it doesn't exist
/** Get a generic header with removing the carriage return If there is multiple headers with the same name, return the first@param string $headerThe header to get@param array $headersThe _headersArray array@returnstring|bool the literal value or false if it doesn't exist
/**
Get all the headers, in the order in EML. The format is
[] => array ("header" => "value")
@param array|null $headers The headers to examine
@return array
/**
Return the complete mail
@return string The complete mail
/**
Get the To Header as it is written in the mail
@return string The To Header defined in the mail
/**
Create a messageID
@return string the textual MessageID
/**
Read the complete mail to analyze
Destroy all the previous definitions of mail
@param string $content The complete mail to read
/**
Get the section ID of the main part
@return bool|string the section ID of the main part or FALSE if not found
/** Define a HTML body. If the HTML body already exists, overwrite it If there is an text body, manage the boundary in alternative mode@param string $htmlContentin UTF-8@param string $charsetto be stored in the mail@param string $encodingthe encoding in the mail
/** Add a Text body. If the text body already exists, overwrite it If there is an HTML body, manage the boundary in alternative mode@param string $textContentin UTF-8@param string $charsetto be stored in the mail@param string $encodingthe encoding in the mail
/**
Set the Date
@param string $date In RFC 2822 format
/**
Set the Date
@param string $timestamp In Timestamp format
/** Add a From: header. If it already exists, overwrite the existing one@param string $fromMailThe from Mail to define@param string|null $fromNameThe from Name to define
/** Set a generic header@param string $headerThe name of the Header (without colon)@param string $valueThe value the store. The format must be correct !@param string|null $sectionIDThe section to modify. If null, use the main
/**
Set the subject
@param string $subject In UTF8