Learn DooPHP: High performance PHP framework

DooMailer learn how to send emails with new DooMailer class

In this tutorial we will learn to send emails, I just finished first version of DooMailer, it starts with calling DooMailer class:

$mail = new DooMailer();

You can add charset in constructor of DooMailer, default is utf-8.
Everything is pretty easy here is the code:


$mail = new DooMailer();
 $mail->addTo('yyyyy@yyyyy.yyy');
 $mail->addTo('xxxx@xxxx.xxx', 'John Smith');
 $mail->setSubject("This is test subject!");
 $mail->setBodyText("This is plain text body");
 $mail->setBodyHtml("<b>This is HTML body!</b>");
$mail->addAttachment('/var/web/files/file1.jpg');
 $mail->addAttachment('/var/web/files/file2.zip');
 $mail->setFrom('doo@xxxxxxxx.xxx', 'DooPHP ');
 $mail->send();

*** Added new option in setSubject function for forcing encoding of subject:

$mail->setSubject('subject of mail', true);

So as you can see everything is pretty easy, you add to add html body or text body and you can add attachments, when you are adding attachment you just provide link to the file on your website.
And then just do send() it returns true if mail is sent and false if not.


  • Does this class support sending images embedded within an HTML message?

  • this is a nice wrapper class for mail()

  • hi Mil0s, thank you very much. Its really convenient with DooMailer where I gonna add it into my personal project which I have not finished yet

  • @Roman there is possibility that you can make image ih html body of email, but script doesnt do it automatic, tnx for asking that question I will add that functionality in final class that will come out soon.

    @vickie
    No problem I am glad I can help, if you need any help plz do ask or message me, if you are female I am glad even more :)

  • I wonder if this class support gmail’s imap4 or ssl-smtp?Thx!

  • Not yet, but something like that will be added in future.

  • look forward to support gmail!

  • Hi, Milos
    Just found DooPHP a couple of days ago, and i’m loving it!

    Regarding this example:
    “Class ‘DooMailer’ not found”, using lastest trunk…
    (Same goes with FlashMessenger class…)

    Any help here, please?
    Thank you.

  • Hi, I am glad you are loving it :)

    In bootstrap put:

    include $config['BASE_PATH'].’helper/DooForm.php’;

    We will sort that autoload stuff in DooPhp 1.3