Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'mandrill-api-php/src/Mandrill.php';
- $servername = "localhost";
- $username = "root";
- $password = "";
- $table = '';
- $conn = mysql_connect($servername, $username, $password);
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }
- $selected = mysql_select_db("DB Name")
- or die("Could not select database");
- $query=mysql_query(Query);
- $table .= "<table width='auto' height='auto' border='1' bordercolor='#003399' style='color:#FF0000;table-layout:fixed' cellpadding=0 cellspacing=0>
- <tr>
- <th>User ID</th>
- <th>Full Name</th>
- <th>Username</th>
- <th>Email ID</th>
- </tr>";
- while($row = mysql_fetch_array($query))
- {
- $table .= "<tr>";
- $table .= "<td>" . $row['id'] . "</td>";
- $table .= "<td>" . $row['fullname'] . "</td>";
- $table .= "<td>" . $row['username'] . "</td>";
- $table .= "<td>" . $row['useremail'] . "</td>";
- $table .= "</tr>";
- }
- $table .= "</table><br>";
- try {
- $mandrill = new Mandrill(API Key);
- $message = array(
- 'html' => $table,
- 'subject' => 'Notification Email',
- 'from_email' => 'Example@example.com',
- 'from_name' => 'Test',
- 'to' => array(
- array(
- 'email' => 'Example@example.com',
- 'name' => 'Test',
- 'type' => 'to'
- )
- ),
- 'important' => false,
- 'track_opens' => null,
- 'track_clicks' => null,
- 'auto_text' => null,
- 'auto_html' => null,
- 'inline_css' => null,
- 'url_strip_qs' => null,
- // A mandrill error occurred: Mandrill_Unknown_Subaccount - No subaccount exists with the id 'customer-123'
- throw $e;
- }
- ?>
- 'preserve_recipients' => null,
- 'view_content_link' => null,
- 'tracking_domain' => null,
- 'signing_domain' => null,
- 'return_path_domain' => null,
- );
- $async = false;
- $result = $mandrill->messages->send($message, $async);
- print_r($result);
- }
- catch(Mandrill_Error $e) {
- echo 'A mandrill error occurred: ' . get_class($e) . ' - ' . $e->getMessage();
- throw $e;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement