mirror of
https://github.com/moodle/moodle.git
synced 2025-01-22 16:18:24 +01:00
86 lines
2.9 KiB
Plaintext
86 lines
2.9 KiB
Plaintext
|
phpmailer - PHP email class
|
|||
|
==============================
|
|||
|
http://phpmailer.sourceforge.net
|
|||
|
|
|||
|
Please read LICENSE for information on this softwares availability and
|
|||
|
distribution.
|
|||
|
|
|||
|
Class Features:
|
|||
|
- Send emails with multiple TOs, CCs, BCCs and REPLY-TOs
|
|||
|
- Redundant SMTP servers
|
|||
|
- Multipart/alternative emails for mail clients that do not read HTML email
|
|||
|
- Support for 8bit, base64, binary, and quoted-printable encoding
|
|||
|
- Uses the same methods as the very popular AspEmail active server (COM) component
|
|||
|
- SMTP authentication
|
|||
|
- Word wrap
|
|||
|
- Many more...
|
|||
|
|
|||
|
Why you might need it:
|
|||
|
|
|||
|
Many PHP developers utilize email in their code. The only PHP function
|
|||
|
that supports this is the mail() function. However, it does not expose
|
|||
|
any of the popular features that many email clients use nowadays like
|
|||
|
HTML-based emails and attachments. There are two proprietary
|
|||
|
development tools out there that have all the functionality built into
|
|||
|
easy to use classes: AspEmail(tm) and AspMail. Both of these
|
|||
|
programs are COM components only available on Windows. They are also a
|
|||
|
little pricey for smaller projects.
|
|||
|
|
|||
|
Since I do Linux development I<>ve missed these tools for my PHP coding.
|
|||
|
So I built a version myself that implements the same methods (object
|
|||
|
calls) that the Windows-based components do. It is open source and the
|
|||
|
LGPL license allows you to place the class in your proprietary PHP
|
|||
|
projects.
|
|||
|
|
|||
|
|
|||
|
Installation:
|
|||
|
|
|||
|
Copy class.phpmailer.php into your php.ini include_path. If you are
|
|||
|
using the SMTP mailer then place class.smtp.php in your path as well.
|
|||
|
|
|||
|
Example
|
|||
|
|
|||
|
<?php
|
|||
|
require("class.phpmailer.php");
|
|||
|
|
|||
|
$mail = new phpmailer();
|
|||
|
|
|||
|
$mail->IsSMTP(); // set mailer to use SMTP
|
|||
|
$mail->Host = "smtp1.site.com;smtp2.site.com"; // specify main and backup server
|
|||
|
$mail->SMTPAuth = true // turn on SMTP authentication
|
|||
|
$mail->Username = "jswan" // SMTP username
|
|||
|
$mail->Password = "secret" // SMTP password
|
|||
|
|
|||
|
$mail->From = "from@email.com";
|
|||
|
$mail->FromName = "Mailer";
|
|||
|
$mail->AddAddress("josh@site.com", "Josh Adams");
|
|||
|
$mail->AddAddress("ellen@site.com"); // name is optional
|
|||
|
$mail->AddReplyTo("info@site.com", "Information");
|
|||
|
|
|||
|
$mail->WordWrap = 50; // set word wrap to 50 characters
|
|||
|
$mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments
|
|||
|
$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name
|
|||
|
$mail->IsHTML(true); // set email format to HTML
|
|||
|
|
|||
|
$mail->Subject = "Here is the subject";
|
|||
|
$mail->Body = "This is the HTML message body <b>in bold!</b>";
|
|||
|
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
|
|||
|
|
|||
|
if(!$mail->Send())
|
|||
|
{
|
|||
|
echo "Message could not be sent. <p>";
|
|||
|
echo "Mailer Error: " . $mail->ErrorInfo;
|
|||
|
exit;
|
|||
|
}
|
|||
|
|
|||
|
echo "Message has been sent";
|
|||
|
?>
|
|||
|
|
|||
|
CHANGELOG
|
|||
|
|
|||
|
See ChangeLog.txt
|
|||
|
|
|||
|
Download: http://sourceforge.net/project/showfiles.php?group_id=26031
|
|||
|
|
|||
|
Brent R. Matzelle <bmatzelle@yahoo.com>
|