\Pluf_Mail_Batch

Generate and send multipart emails in batch mode.

This class is just a small wrapper around the PEAR packages Mail and Mail/mime.

Class to easily generate multipart emails. It supports embedded images within the email. It can be used to send a text with possible attachments.

The encoding of the message is utf-8 by default.

Usage example: $email = new Pluf_Mail_Batch('from_email@example.com'); foreach($emails as $m) { $email->setSubject($m['subject']); $email->setTo($m['to']); $img_id = $email->addAttachment('/var/www/html/img/pic.jpg', 'image/jpg'); $email->addTextMessage($m['content']); $email->sendMail(); } $email->close();

The configuration parameters are the one for Mail::factory with the 'mail_' prefix not to conflict with the other parameters.

Summary

Methods
Properties
Constants
__construct()
setSubject()
setTo()
addTextMessage()
setReturnPath()
addHeaders()
addHtmlMessage()
addAttachment()
sendMail()
close()
$headers
$message
$encoding
$crlf
$from
No constants found
No protected methods found
$backend
N/A
No private methods found
No private properties found
N/A

Properties

$headers

$headers : 

Type

$message

$message : 

Type

$encoding

$encoding : 

Type

$crlf

$crlf : 

Type

$from

$from : 

Type

$backend

$backend : 

Type

Methods

__construct()

__construct(  $src,   $encoding = 'UTF-8',   $crlf = "\n") 

Construct the base email.

Parameters

$src
$encoding
$crlf

setSubject()

setSubject(  $subject) 

Set the subject of the email.

Parameters

$subject

setTo()

setTo(  $email) 

Set the recipient of the email.

Parameters

$email

addTextMessage()

addTextMessage(  $msg) 

Add the base plain text message to the email.

Parameters

$msg

setReturnPath()

setReturnPath(  $email) 

Set the return path for the email.

Parameters

$email

addHeaders()

addHeaders(  $hdrs) 

Add headers to an email.

Parameters

$hdrs

addHtmlMessage()

addHtmlMessage(  $msg) 

Add the alternate HTML message to the email.

Parameters

$msg

addAttachment()

addAttachment(  $file,   $ctype = 'text/plain') : boolean

Add an attachment to the message.

The file to attach must be available on disk and you need to provide the mimetype of the attachment manually.

Parameters

$file
$ctype

Returns

boolean —

True.

sendMail()

sendMail() 

Effectively sends the email.

close()

close()