$sessionid = bin2hex($sbytes); $activationid = bin2hex($abytes); $sql = "SELECT ID FROM users WHERE sessionid = '{$sessionid}' OR\n\t\tactivationid = '{$activationid}'"; $result = mysqli_query($con, $sql); } while (mysqli_num_rows($result) > 0); $hashed_pw = password_hash($password, PASSWORD_DEFAULT); $sql = "INSERT IGNORE INTO users (email, username, userpass, IP_address,\n\tregistration_date, sessionid, activationid) VALUES ('{$email}', '{$username}',\n\t'{$hashed_pw}', INET_ATON('{$IP_address}'), NOW(), '{$sessionid}', '{$activationid}')"; if (!mysqli_query($con, $sql)) { die("Sign up failed."); } mysqli_close($con); $mail = new PHPMailer(); $mail->IsSMTP(); //$mail->SMTPDebug = 1; $mail->SMTPAuth = true; $mail->SMTPSecure = 'ssl'; $mail->Host = "smtp.gmail.com"; $mail->Port = 465; // or 587 $mail->IsHTML(true); $mail->Username = EMAIL_USERNAME; $mail->Password = EMAIL_PASSWORD; $mail->SetFrom(EMAIL_USERNAME, 'notePHPad'); $mail->Subject = "Account Activation"; $mail->Body = getEmailBody($username, $activationid); $mail->AddAddress($email); if (!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "SUCCESS"; }
function sendTemplateEmail($to, $subject_path, $body_path, $template_vars) { $app_config = getConfig(); $email_from_address = '*****@*****.**'; include 'config.php'; $subject_path = $app_config['document_root'] . "/" . $subject_path; $body_path = $app_config['document_root'] . "/" . $body_path; //$headers = "From:$email_from_address\n"; $headers = "From:{$email_from_address}\n"; $email_subject_body = getEmailTemplateBody($subject_path); $email_template_body = getEmailTemplateBody($body_path); $email_body = getEmailBody($email_template_body, $template_vars); $email_subject = getEmailBody($email_subject_body, $template_vars); #echo "$email_subject"; #echo "$email_body"; #echo " $to"; mail($to, $email_subject, $email_body, $headers); }
function bodycontent() { $body_language = $_POST['body_language']; $body_id = (int) $_POST['body_id']; $sresult = getEmailBody($body_language, $body_id); foreach ($sresult as $value) { echo $value['translated_body']; } }