Wordpress HTML Mail code.
This tutorial is all about the sending the html mail via wordppress code and here some more code help to under stand how to get the info from the database using the wp functions and then how to prepare that information for a html mail. Within this page you can get how query the data from a table in wp, also you can find the code how can update date using the wp query and then you can find the how to define the subject of the html mail. There is code line available for html header that the header of the html content mail, this is required header. The the proper body of message is defined for multiple lines mail of html content embedded or concatenated the query fetched data. The the 'wp_mail' function used to send the mail this mail have some parameter that we defined before this method call. after the wp redirect code is also available so that user can redirected to mentioned location.
// REJECT
if($_GET['action']=="reject")
{
global $wpdb;
// GET USER INFO
$query1 = "SELECT * FROM ".$table_name." WHERE id_rs ='".$_GET['id_sr']."' ";
$result1 = $wpdb->get_row($query1);
// UPDATE THE TABLE
$query = "UPDATE ".$table_name." SET status='reject' WHERE id_rs ='".$_GET['id_sr']."' ";
$result = $wpdb->query($query);
$wpdb->show_errors();
// Reject mail to user
$subject = 'Shop add Request "Reject" for "'.$result1->registered_name.'" ';
$headers = array('Content-Type: text/html; charset=UTF-8');
// Mail Body
$body = '<table style="text-align:left;margin:20px 0;padding:5px;" cellpadding="5">';
$body .= '<tr><th>Alias Name:</th><td>'.$result1->name.'</td></tr>';
$body .= '<tr><th>Description:</th><td>'.$result1->description.'</td></tr>';
// $body .= '<tr><th>Photo:</th><td>'.$result1->photo.'</td></tr>';
$body .= '<tr><th>Registred Name:</th><td>'.$result1->registered_name.'</td></tr>';
$body .= '<tr><th>Address Line 1:</th><td>'.$result1->address_line1.'</td></tr>';
$body .= '<tr><th>Address Line 2:</th><td>'.$result1->address_line2.'</td></tr>';
$body .= '<tr><th>City:</th><td>'.$result1->city.'</td></tr>';
$body .= '<tr><th>State:</th><td>'.$result1->state.'</td></tr>';
$body .= '<tr><th>Country:</th><td>'.$result1->country.'</td></tr>';
$body .= '<tr><th>Pin:</th><td>'.$result1->pin.'</td></tr>';
$body .= '<tr><th>Phone:</th><td>'.$result1->phone.'</td></tr>';
$body .= '<tr><th>Mobile:</th><td>'.$result1->mobile.'</td></tr>';
$body .= '<tr><th>Contact Person:</th><td>'.$result1->contact_person.'</td></tr>';
$body .= '<tr><th>Email:</th><td>'.$result1->email.'</td></tr>';
$body .= '</table>';
// User mail
$usermail = '<b>You add shop request "Reject" Due to invaldi infromation. Please try again with the geniun infromation.</b>';
$usermail .= $body;
wp_mail( $result1->email, $subject, $usermail, $headers );
$url = "/wp-admin/admin.php?page=shop-requests/shop-requests.php&id_sr=".$_GET['id_sr']."&status=reject";
wp_redirect( $url );
exit;
}
This tutorial is all about the sending the html mail via wordppress code and here some more code help to under stand how to get the info from the database using the wp functions and then how to prepare that information for a html mail. Within this page you can get how query the data from a table in wp, also you can find the code how can update date using the wp query and then you can find the how to define the subject of the html mail. There is code line available for html header that the header of the html content mail, this is required header. The the proper body of message is defined for multiple lines mail of html content embedded or concatenated the query fetched data. The the 'wp_mail' function used to send the mail this mail have some parameter that we defined before this method call. after the wp redirect code is also available so that user can redirected to mentioned location.
// REJECT
if($_GET['action']=="reject")
{
global $wpdb;
// GET USER INFO
$query1 = "SELECT * FROM ".$table_name." WHERE id_rs ='".$_GET['id_sr']."' ";
$result1 = $wpdb->get_row($query1);
// UPDATE THE TABLE
$query = "UPDATE ".$table_name." SET status='reject' WHERE id_rs ='".$_GET['id_sr']."' ";
$result = $wpdb->query($query);
$wpdb->show_errors();
// Reject mail to user
$subject = 'Shop add Request "Reject" for "'.$result1->registered_name.'" ';
$headers = array('Content-Type: text/html; charset=UTF-8');
// Mail Body
$body = '<table style="text-align:left;margin:20px 0;padding:5px;" cellpadding="5">';
$body .= '<tr><th>Alias Name:</th><td>'.$result1->name.'</td></tr>';
$body .= '<tr><th>Description:</th><td>'.$result1->description.'</td></tr>';
// $body .= '<tr><th>Photo:</th><td>'.$result1->photo.'</td></tr>';
$body .= '<tr><th>Registred Name:</th><td>'.$result1->registered_name.'</td></tr>';
$body .= '<tr><th>Address Line 1:</th><td>'.$result1->address_line1.'</td></tr>';
$body .= '<tr><th>Address Line 2:</th><td>'.$result1->address_line2.'</td></tr>';
$body .= '<tr><th>City:</th><td>'.$result1->city.'</td></tr>';
$body .= '<tr><th>State:</th><td>'.$result1->state.'</td></tr>';
$body .= '<tr><th>Country:</th><td>'.$result1->country.'</td></tr>';
$body .= '<tr><th>Pin:</th><td>'.$result1->pin.'</td></tr>';
$body .= '<tr><th>Phone:</th><td>'.$result1->phone.'</td></tr>';
$body .= '<tr><th>Mobile:</th><td>'.$result1->mobile.'</td></tr>';
$body .= '<tr><th>Contact Person:</th><td>'.$result1->contact_person.'</td></tr>';
$body .= '<tr><th>Email:</th><td>'.$result1->email.'</td></tr>';
$body .= '</table>';
// User mail
$usermail = '<b>You add shop request "Reject" Due to invaldi infromation. Please try again with the geniun infromation.</b>';
$usermail .= $body;
wp_mail( $result1->email, $subject, $usermail, $headers );
$url = "/wp-admin/admin.php?page=shop-requests/shop-requests.php&id_sr=".$_GET['id_sr']."&status=reject";
wp_redirect( $url );
exit;
}