require_once "utils/email_utils.php"; require_once "utils/db_utils.php"; require_once "utils/file_utils.php"; $con = db_connect(); $email_template = "email_article_template.html"; $email_sent = ""; $article_id = $_GET["aid"]; $type = $_GET["t"]; if (empty($type)) $type = "article"; if($_SERVER['REQUEST_METHOD'] == "POST"){ $name = mysql_real_escape_string($_POST["name"]); $from_email = mysql_real_escape_string($_POST["from_email"]); $to_email_1 = mysql_real_escape_string($_POST["to_email_1"]); $to_email_2 = mysql_real_escape_string($_POST["to_email_2"]); $comments = mysql_real_escape_string($_POST["comments"]); $type = $_POST["t"]; if (empty($type)) $type = "article"; $article_id = $_POST["id"]; $subject = "Email from " . $name; if ($type == "tvc"){ $url = "
Please click here
to check out this article."; } else{ $url = "
Please click here
to check out this article."; } //SEND THE EMAIL $email_body = read_file($email_template); $email_body = str_replace("##name##", $name, $email_body); $email_body = str_replace("##comments##", $comments, $email_body); $email_body = str_replace("##url##", $url, $email_body); if ($to_email_1 != ""){ phpmail($from_email, $to_email_1, $subject, $email_body, "html"); $email_sent = "1"; } if ($to_email_2 != ""){ phpmail($from_email, $to_email_2, $subject, $email_body, "html"); $email_sent = "1"; } if ($from_email != "" && $to_email_1 != ""){ $to_email = ($to_email_2 != "")?($to_email_1 . ", " . $to_email_2):($to_email_1); $message = str_replace("'", "", $message); $type_str = ($type == "tvc")?"T":"A"; $ins_qry = "INSERT INTO SendEmails(ArticleId, FromEmail, ToEmail, Message, Type) VALUES('$article_id', '$from_email', '$to_email', '$comments', '$type_str')"; $ins_res = mysql_query($ins_qry) or die(mysql_error()); } } if ($email_sent == "1"){ ?>
Email has been sent. Thank you!
} ?>
Your Name :
Your Email :
Friend's Email 1 :
Friend's Email 2 :
(optional)
Comments :