/openshift/adei

To get this branch, use:
bzr branch http://darksoft.org/webbzr/openshift/adei

« back to all changes in this revision

Viewing changes to includes/PHPMailer-Lite_v5.1/examples/test_db_basic.php

  • Committer: Suren A. Chilingaryan
  • Date: 2011-01-26 02:48:39 UTC
  • mto: This revision was merged to the branch mainline in revision 212.
  • Revision ID: csa@dside.dyndns.org-20110126024839-nv6qp2ie9stmd2dn
Support of Appled devices by Toni Pirhonen

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<html>
 
2
<head>
 
3
<title>PHPMailer - MySQL Database - SMTP basic test with authentication</title>
 
4
</head>
 
5
<body>
 
6
 
 
7
<?php
 
8
 
 
9
//error_reporting(E_ALL);
 
10
error_reporting(E_STRICT);
 
11
 
 
12
date_default_timezone_set('America/Toronto');
 
13
 
 
14
require_once('../class.phpmailer-lite.php');
 
15
 
 
16
$mail             = new PHPMailerLite(); // defaults to using php "Sendmail" (or Qmail, depending on availability)
 
17
 
 
18
$body                = file_get_contents('contents.html');
 
19
$body                = eregi_replace("[\]",'',$body);
 
20
 
 
21
$mail->SetFrom('list@mydomain.com', 'List manager');
 
22
 
 
23
$mail->Subject       = "PHPMailer Test Subject via Sendmail";
 
24
 
 
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);
 
29
 
 
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");
 
35
 
 
36
  if(!$mail->Send()) {
 
37
    echo "Mailer Error (" . str_replace("@", "&#64;", $row["email"]) . ') ' . $mail->ErrorInfo . '<br />';
 
38
  } else {
 
39
    echo "Message sent to :" . $row["full_name"] . ' (' . str_replace("@", "&#64;", $row["email"]) . ')<br />';
 
40
  }
 
41
  // Clear all addresses and attachments for next loop
 
42
  $mail->ClearAddresses();
 
43
  $mail->ClearAttachments();
 
44
}
 
45
?>
 
46
 
 
47
</body>
 
48
</html>