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:

1.
$mail = new DooMailer();
You can add charset in constructor of DooMailer, default is utf-8.
Everything is pretty easy here is the code:

01.
$mail = new DooMailer();
02.
$mail->addTo(‘[email protected]’);
03.
$mail->addTo(‘[email protected]’, ‘John Smith’);
04.
$mail->setSubject(“This is test subject!”);
05.
$mail->setBodyText(“This is plain text body”);
06.
$mail->setBodyHtml(“This is HTML body!“);
07.
$mail->addAttachment(‘/varfile1.jpg’);
08.
$mail->addAttachment(‘/varfile2.zip’);
09.
$mail->setFrom(‘[email protected]’, ‘DooPHP ‘);
10.
$mail->send();
*** Added new option in setSubject function for forcing encoding of subject:

1.
$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.

Previous PostNextNext Post

Leave a Reply

Your email address will not be published.