Rmail is a PHP class for sending a wide variety of types of email in PHP. Amongst others, it can send:
Basically, if there's a type of email you want to send, this class can probably do it!
Here follows a list of methods available to you to use and what they do.g
-
constructor
Nothing to pass to it. It only serves to initialise the email.
$mail = new Rmail();
-
setCRLF($crlf)
Set the line ending used. Defaults to \r\n. If this is not working for you, (it does most of the time),
you could try \n instead.
$mail->setCRLF("\r\n");
-
setSMTPParams([$host[, $port[, $helo[, $auth[, $user[, $pass]]]]])
The parameters that you can use to setup the SMTP connection. $host is the hostname or IP address to connect to.
$port is the port the server runs on.$helo is the SMTP HELO phrase to use. $auth is a boolean controlling whether
to use authentication. $user is the username to use with authentication, and $pass is the password to use.
$mail->setSMTPParams('mail.example.com', 25, 'my.host.com', true, 'user', 'pass');
-
setSendmailPath($path)
This is the string (eg /usr/lib/sendmail -ti) to use when sending via a sendmail binary.
$mail->setSendmailPath('/usr/lib/sendmail -ti');
-
setTextEncoding($encoding)
This is an encoding object to use when encoding the text. eg $mail->setTextEncoding(new SevenBitEncoding()).
$mail->setTextEncoding(new SevenBitEncoding());
-
setHTMLEncoding($encoding)
This is an encoding object to use when encoding the HTML..
$mail->setHTMLEncoding(new QPrintEncoding());
-
setTextCharset($charset)
Sets the character set to set for the text part of the email. Default is ISO-8859-1
$mail->setTextCharset('ISO-8859-1');
-
setHTMLCharset($charset)
Sets the character set to set for the HTML part of the email. Default is ISO-8859-1
$mail->setHTMLCharset('ISO-8859-1');
-
setHeadCharset($charset)
Sets the character set to set for the email headers. Default is ISO-8859-1
$mail->setHeadCharset('ISO-8859-1');
-
setTextWrap($length)
Sets the point at which long line are wrapped. Default is 998.
$mail->setTextWrap(998);
-
setHeader($name, $value)
Sets a header to add to the email. You can use this to add custom headers to the email if you wish.
$mail->setHeader('Reply-To', 'bob@example.com');
-
setReceipt($email)
Sets an email for a receipt to be sent to. This is dependent on the recipient of the email and their email
software.
$mail->setReceipt('me@domain.com');
-
setSubject($subject)
Sets the subject of the email.
$mail->setSubject('An example subject');
-
setFrom($from)
Sets the From: address used in the email.
$mail->setFrom('me@example.com');
-
setPriority($priority)
Sets the priority of the email. You can specify the priority as: low, normal, high, 1, 3, 5
Default is normal.
$mail->setPriority('high');
-
setReturnPath($return_path)
Sets the Return-Path: email address for bounces. Your server may change this.
$mail->setReturnPath('bounces@example.com');
-
setCc($cc)
Sets the Cc: header of the email.
$mail->setCc('fred@example.com');
-
setBcc($bcc)
Sets the Bcc: header of the email.
$mail->setBcc('jemima@example.com');
-
setText($text)
Sets the plain text part of the email.
$mail->setText('The plain text part');
-
setHTML($html[, $images_dir])
Sets the HTML part of the email. When you do this the class will try to find any images used
in the HTML in images directory you have given. If it finds them, it will embed them.
$mail->setHTML('The <b>HTML</b> part', './images');
-
addAttachment(new FileAttachment($filename))
Add an attachment to the email. This reads in the file you specify and attempts to attach it.
$mail->addAttachment(new FileAttachment('foo.zip'));
-
send($addresses[, $method])
Unsurprisingly, sends the email. Pass this an array of email addresses and it will attempt
to send the email to each. $method can be one of: mail - sends the email using the PHP
mail() function, sendmail - the email will sent using the sendmail binary directly
or smtp - the email will be sent over the network using SMTP.
$mail->send(array('barry@example.com'));
-
getRFC822($recipients[, $method])
Builds the email and returnss it as text instead of sending it. This can used in the event
that you want to attach one email to another. You can build an email, get it using this
method, and then attach to another using addAttachment(). The $method argument
should be the same as that used when you call send(). If you don't specify one then,
don't specify one here. It's simply used to ensure the correct line-ending is used.
$source = $mail->getRFC822(array('richard@example.com'));