예제 #1
0
 ** 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 = '*****@*****.**';
$to = array('richard@[10.1.1.2]', 'cc-recipient@[10.1.1.2]', 'bcc-recipient@[10.1.1.2]');
$headers = array('From: "Joe" <*****@*****.**>', 'Subject: Example email using HTML Mime Mail class', 'To: "Richard" <richard@[10.1.1.2]>', 'Cc: cc-recipient@[10.1.1.2]');
$mail->smtp_send($smtp, $from, $to, $headers);
/***************************************
 ** Debug stuff. Entirely unnecessary.
 ***************************************/
echo '<PRE>' . htmlentities($mail->get_rfc822('Richard', 'richard@[10.1.1.2]', 'Joe', '*****@*****.**', 'Example email using HTML Mime Mail class')) . '</PRE>';
예제 #2
0
$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>';