phool4fool
203.***.***.***XPertMailer Class
XPertMailer is a php class that you can use to send encoded MIME type e-mail messages (text, HTML, HTML embeded images, attachments) towards a localhost, client, or relay SMTP servers with optional authorisation.PHP Example: (!)
PHP code:
0<?php
1
2/********************************************************************
3 * XPertMailer is a php class that you can use to send encoded *
4 * MIME type e-mail messages (text, HTML, HTML embeded images, *
5 * attachments) towards a localhost, client or relay SMTP servers *
6 * with optional authorisation *
7 * ---------------------------------------------------------------- *
8 * For more informations, please visit: http://www.xpertmailer.com/ *
9 ********************************************************************/
10
11@set_time_limit(0);
12@error_reporting(E_ALL); // for debugging
13
14// you will need to download the latest version of XPertMailer from
15// http://sourceforge.net/projects/xpertmailer/
16require_once 'XPertMailer.php';
17
18/**
19 * send a complex mail - text/html format
20 * with two HTML embeded images and two attachment files
21 * --------------------------------------
22 */
23
24// $mail = new XPertMailer; // <-- by default SMTP_LOCAL_CLIENT
25// but you can optionaly use an relay host (name or ip)
26$mail = new XPertMailer(SMTP_RELAY, "relay-host-name.com");
27
28// optionaly you can set authentification for relay host
29$mail->auth("username", "password");
30
31// optionaly you can set time out for each smtp server connection
32$mail->timeout(30);
33
34// optionaly you can set priority high (default is P_NORMAL - normal)
35$mail->priority(P_HIGH);
36
37// optionaly you can set from mail address and optionaly from name
38$mail->from("my@account.com", "My Name");
39
40// optionaly you can set each header name and value
41$header['Cc'] = "example1@domain.com";
42$header['Bcc'] = "example2@domain.com";
43$header['Reply-To'] = "reply@domain.com";
44$header['X-Whatever'] = "description";
45
46// set additional header informations
47$mail->headers($header);
48
49// set HTML embedded images name and optionaly you can rename them
50// if the file is not in this directory, write the path name
51// Attention: do not include path name in the rename
52$imgs[] = "image1.jpg";
53$imgs['newname.gif'] = "image2.gif";
54
55// attach HTML embedded images
56$mail->attach($imgs, ATTACH_HTML_IMG);
57
58// set attachment files name and optional you can rename them
59// if the file is not in this directory, write the path name
60$file['new.zip'] = "archive1.zip";
61$file[] = "archive2.tar.gz";
62
63// attach files
64$mail->attach($file, ATTACH_FILE);
65
66// set the HTML message value
67// Attention: do not include image path name
68$html = '
69<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
70<html>
71<body>
72<img src="image1.jpg" border="0"><br>
73<b><u><i>next image</i></u></b> :-)<br>
74<img src="newname.gif" border="2"><br>
75<font color="red">message html red here</font>
76</body>
77</html>';
78
79// send the e-mail and optionaly you can set charset value
80// as you can see, the text/plain message is required because
81// not all mail clients can currently support HTML messages
82$send = $mail->send("expertphp@domain.com", "subject here",
83 "this is a HTML message", $html, "UTF-8");
84
85// output -->
86// compare the result and print a message
87echo $send ? "Done." : "Error.";
88
89// some useful for debugging
90echo "<br>Server response: ".$mail->response();
91
92?>