Email - adampatterson/Dingo-Framework GitHub Wiki

Overview

The email library allows you to easily send HTML emails to one person or a group of people. To load the email library manually you may do this:

load::library('email');

Index

  • Basic Usage
  • Multiple Recipients
  • Attachments

###Basic Usage Sending an email to one person is pretty straight forward:

$mail = new email();
$mail->to('[email protected]');
$mail->from('Your Name <[email protected]>');
$mail->subject('Testing');
$mail->content('<strong>Hello, World!</strong>');
$mail->send();

###Multiple Recipients Sending an email to many persons is pretty easy as well:

$mail = new email();
$mail->to('[email protected]');
$mail->to('[email protected]');
$mail->to('[email protected]');
$mail->from('Your Name <[email protected]>');
$mail->subject('Testing');
$mail->content('<strong>Hello, World!</strong>');
$mail->send();

The email library sends a seperate email to each recipient, so there is no limit as to how many people you can send one email to and you do not have to worry about other people seeing each others email addresses.

The above three to() methods can also be combined into one:

$mail = new email();
$mail->to('[email protected]','[email protected]','[email protected]');
$mail->from('Your Name <[email protected]>');
$mail->subject('Testing');
$mail->content('<strong>Hello, World!</strong>');
$mail->send();

And if you want to get really fancy you could format the above code like so:

$mail = new email();
$mail->to('[email protected]','[email protected]','[email protected]')
    ->from('Your Name <[email protected]>')
    ->subject('Testing')
    ->content('<strong>Hello, World!</strong>')
    ->send();

###Attachments You can easily attach multiple files to an e-mail.

$mail = new email();
$mail->to('[email protected]');
$mail->from('Your Name <[email protected]>');
$mail->subject('Testing');
$mail->content('<strong>Hello, World!</strong>');
$mail->attachment('file.jpg');
$mail->attachment('another.zip','application/octet-stream','new-name.zip');
$mail->send();

The first argument is the local file that you want to attach. The second argument is the content MIME type and the default value is application/octet-stream. The last argument allows you to specify a new file name for the attached file.

⚠️ **GitHub.com Fallback** ⚠️