Ejemplo n.º 1
0
<?php

extract($_REQUEST);
if (!isset($email)) {
    echo json_encode(array("status" => "fail", "reason" => "no email"));
    return;
}
$resp = sendTheMail($email, "Confirmation", "Thanks for visiting TravCork! <br><br>Your request is currently being processed. We will contact you as soon as we confirm the best date. Please standby.", "Thanks for visiting TravCork!<br><br>-TravCork \n\nYour request is currently being processed. We will contact you as soon as we confirm the best date. Please standby.\n\n -TravCork Support");
$resp1 = sendTheMail("*****@*****.**", "Someone Wants a Request", "the email is " . $email, "Someone Wants a Request", "the email is " . $email);
echo json_encode($resp);
function sendTheMail($email, $subject, $htmlContent, $textContent)
{
    require_once 'class.phpmailer.php';
    $mail = new PHPMailer();
    $mail->IsSMTP();
    // Set mailer to use SMTP
    $mail->Host = 'smtp.gmail.com';
    // Specify main and backup server
    $mail->SMTPAuth = true;
    // Enable SMTP authentication
    $mail->Username = '******';
    // SMTP username
    $mail->Password = '******';
    // SMTP password
    $mail->SMTPSecure = 'tls';
    // Enable encryption, 'ssl' also accepted
    $mail->From = '*****@*****.**';
    $mail->FromName = "TravCork Support";
    //$mail->AddAddress('*****@*****.**', 'Mariah');  // Add a recipient
    $mail->AddAddress($email);
    // Name is optional
Ejemplo n.º 2
0
<?php

include_once 'db2.php';
include_once 'dbShortcuts.php';
include_once 'emailer.php';
extract($_REQUEST);
if (!isset($siteUrl)) {
    echo $_GET['callback'] . "(" . json_encode(array("result" => "fail", "reason" => "Please send a site URL, idiot!")) . ")";
    return;
}
//get all fields
$elems = $_REQUEST;
echo $_GET['callback'] . '(' . "{'result' : 'success'}" . ')';
//unset variables in array for clean inclusion of just form data
unset($elems['callback']);
//save the email of form recipient before unsetting
$base4Email = $elems['base4Email'];
unset($elems['base4Email']);
//add to db
rollAdd($siteUrl, $elems, false, false, false, false, true);
//send email
$subject = "New form submission from your site";
$htmlContent = "";
foreach ($elems as $key => $value) {
    $htmlContent .= $key . ": " . $value . "<br>";
}
$textContent = str_replace("<br>", "\r\n", $htmlContent);
sendTheMail($base4Email, $subject, $htmlContent, $textContent);