Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. <?php
  2.  
  3. require_once 'mandrill-api-php/src/Mandrill.php';
  4.  
  5. $servername = "localhost";
  6. $username = "root";
  7. $password = "";
  8. $table = '';
  9.  
  10. $conn = mysql_connect($servername, $username, $password);
  11.  
  12.  
  13. if (!$conn) {
  14. die("Connection failed: " . mysqli_connect_error());
  15. }
  16.  
  17.  
  18.  
  19. $selected = mysql_select_db("DB Name")
  20. or die("Could not select database");
  21.  
  22. $query=mysql_query(Query);
  23.  
  24.  
  25. $table .= "<table width='auto' height='auto' border='1' bordercolor='#003399' style='color:#FF0000;table-layout:fixed' cellpadding=0 cellspacing=0>
  26. <tr>
  27. <th>User ID</th>
  28. <th>Full Name</th>
  29. <th>Username</th>
  30. <th>Email ID</th>
  31.  
  32. </tr>";
  33.  
  34. while($row = mysql_fetch_array($query))
  35. {
  36. $table .= "<tr>";
  37. $table .= "<td>" . $row['id'] . "</td>";
  38. $table .= "<td>" . $row['fullname'] . "</td>";
  39. $table .= "<td>" . $row['username'] . "</td>";
  40. $table .= "<td>" . $row['useremail'] . "</td>";
  41. $table .= "</tr>";
  42. }
  43. $table .= "</table><br>";
  44.  
  45.  
  46. try {
  47. $mandrill = new Mandrill(API Key);
  48. $message = array(
  49. 'html' => $table,
  50. 'subject' => 'Notification Email',
  51. 'from_email' => 'Example@example.com',
  52. 'from_name' => 'Test',
  53. 'to' => array(
  54. array(
  55. 'email' => 'Example@example.com',
  56. 'name' => 'Test',
  57. 'type' => 'to'
  58. )
  59. ),
  60. 'important' => false,
  61. 'track_opens' => null,
  62. 'track_clicks' => null,
  63. 'auto_text' => null,
  64. 'auto_html' => null,
  65. 'inline_css' => null,
  66. 'url_strip_qs' => null,
  67. // A mandrill error occurred: Mandrill_Unknown_Subaccount - No subaccount exists with the id 'customer-123'
  68. throw $e;
  69. }
  70. ?>
  71. 'preserve_recipients' => null,
  72. 'view_content_link' => null,
  73. 'tracking_domain' => null,
  74. 'signing_domain' => null,
  75. 'return_path_domain' => null,
  76.  
  77. );
  78. $async = false;
  79. $result = $mandrill->messages->send($message, $async);
  80. print_r($result);
  81.  
  82.  
  83. }
  84. catch(Mandrill_Error $e) {
  85.  
  86. echo 'A mandrill error occurred: ' . get_class($e) . ' - ' . $e->getMessage();
  87.  
  88. throw $e;
  89. }
  90. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement