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 $name
The name of the file@param string $fileContent
The content of the file in binary@param string|null $encoding
The output encoding. Can be base64/quoted-printable@param boolean|null $inline
Store 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 $name
The name of the file@param string $fileContent
The content of the file in binary@param string|null $encoding
The output encoding. Can be base64/quoted-printable@return
string The content ID created
/** Add a generic header@param string $header
The name of the Header (without colon)@param string $value
The value the store. The format must be correct !@param string|null $sectionID
The section to modify. If null, use the main
/** Add a To: header. If it already exists, add a new recipient@param string $toMail
The mail to add@param string|null $toName
The name of the recipient
/** Analyze the Content-Type line and return an array with the values@param string $contentType
The content Type to analyze@return
array 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 $header
The header to remove@param string|null $sectionID
The section to modify. If null, use the main
/** Get an attachment of the mail@param integer $number
the number of attach to get starting to 0@param boolean|null $inline
Return only the attachments Inline if true@return
string the content of the attachment. Can be binary
/** Get the attachment details@param integer $number
the number of attach to get starting to 0@param boolean|null $inline
Return only the attachments Inline if true@return
array 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 $header
The header to get@param array|null $headers
Optional headers to examine@return
string|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 $header
The header to get@param array $headers
The _headersArray array@return
string|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 $htmlContent
in UTF-8@param string $charset
to be stored in the mail@param string $encoding
the 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 $textContent
in UTF-8@param string $charset
to be stored in the mail@param string $encoding
the 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 $fromMail
The from Mail to define@param string|null $fromName
The from Name to define
/** Set a generic header@param string $header
The name of the Header (without colon)@param string $value
The value the store. The format must be correct !@param string|null $sectionID
The section to modify. If null, use the main
/**
Set the subject
@param string $subject
In UTF8