Back to the module list

Create easily a mail

Info : to send the created email, use the smtp class!

Examples

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).

require ("domframework/mail.php");
$mail = new 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 :

require ("domframework/mail.php");
$mail = new 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 :

require ("domframework/mail.php");
$mail = new mail ();
$mail->readMail (file_get_contents ("MAILFILE.eml"));
$mail->getDetails ();

You can get the details of the mails with :

require ("domframework/mail.php");
$mail = new 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 :

require ("domframework/mail.php");
$mail = new mail ();
$mail->readMail (file_get_contents ("MAILFILE.eml"));
$binaryAttachment = $mail->getAttachment (0);