예제 #1
0
define('CRLF', "\r\n", TRUE);
/***************************************
 ** Create the mail object. Optional headers
 ** argument. Do not put From: here, this
 ** will be added when $mail->send
 ** Does not have to have trailing \r\n
 ** but if adding multiple headers, must
 ** be seperated by whatever you're using
 ** as line ending (usually either \r\n or \n)
 ***************************************/
$mail = new html_mime_mail('X-Mailer: Html Mime Mail Class');
/***************************************
 ** We will just send a text email
 ***************************************/
$text = $mail->get_file('example.txt');
$mail->set_body($text);
/***************************************
 ** Builds the message.
 ***************************************/
$mail->build_message();
/***************************************
 ** Send the email using smtp method.
 ** This is the preferred method of sending.
 ***************************************/
include 'class.smtp.inc';
$smtp = new smtp_class();
$smtp->host_name = '10.1.1.2';
// Address/host of mailserver
$smtp->localhost = 'localhost';
// Address/host of this machine (HELO)
$from = '*****@*****.**';
예제 #2
0
$text = $mail_1->get_file('example.txt');
$mail_1->set_body($text);
/***************************************
 ** Add the attachment
 ***************************************/
$file = $mail_1->get_file('example.zip');
$mail_1->add_attachment($file, 'example.zip', 'application/zip');
/***************************************
 ** Builds the message.
 ***************************************/
$mail_1->build_message();
/***************************************
 ** Don't send this email, but use the
 ** get_rfc822() method to assign it to a
 ** variable.
 ***************************************/
$mail = $mail_1->get_rfc822('John Doe', '*****@*****.**', 'Some one', '*****@*****.**', 'Test for attached email');
/***************************************
 ** Now start a new mail, and add the first
 ** (which is now built and contained in
 ** $mail) to it.
 ***************************************/
$mail_2 = new html_mime_mail('X-Mailer: Html Mime Mail Class');
$mail_2->set_body('This email has an attached email');
$mail_2->add_attachment($mail, 'Test for attached email', 'message/rfc822');
$mail_2->build_message();
$mail_2->send('Richard Heyes', 'richard@[10.1.1.2]', 'A Nother', '*****@*****.**', 'This email has another email attached');
/***************************************
 ** Debug stuff. Entirely unnecessary.
 ***************************************/
echo '<PRE>' . htmlentities($mail_2->get_rfc822('Richard Heyes', 'richard@[10.1.1.2]', 'A Nother', '*****@*****.**', 'This email has another email attached')) . '</PRE>';