3
<title>PHPMailer - MySQL Database - SMTP basic test with authentication</title>
9
//error_reporting(E_ALL);
10
error_reporting(E_STRICT);
12
date_default_timezone_set('America/Toronto');
14
require_once('../class.phpmailer-lite.php');
16
$mail = new PHPMailerLite(); // defaults to using php "Sendmail" (or Qmail, depending on availability)
18
$body = file_get_contents('contents.html');
19
$body = eregi_replace("[\]",'',$body);
21
$mail->SetFrom('list@mydomain.com', 'List manager');
23
$mail->Subject = "PHPMailer Test Subject via Sendmail";
25
@MYSQL_CONNECT("localhost","root","password");
26
@mysql_select_db("my_company");
27
$query = "SELECT full_name, email, photo FROM employee WHERE id=$id";
28
$result = @MYSQL_QUERY($query);
30
while ($row = mysql_fetch_array ($result)) {
31
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
32
$mail->MsgHTML($body);
33
$mail->AddAddress($row["email"], $row["full_name"]);
34
$mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");
37
echo "Mailer Error (" . str_replace("@", "@", $row["email"]) . ') ' . $mail->ErrorInfo . '<br />';
39
echo "Message sent to :" . $row["full_name"] . ' (' . str_replace("@", "@", $row["email"]) . ')<br />';
41
// Clear all addresses and attachments for next loop
42
$mail->ClearAddresses();
43
$mail->ClearAttachments();