$insert = mysql_query($registerSql) or die(mysql_error()); //if inserted, send email if ($insert) { require "lib-external/PHPMailer-Lite_v5.1/class.phpmailer-lite.php"; $mail = new PHPMailerLite(); //$mail->IsSMTP(); $mail->Host = 'ssl://smtp.gmail.com:465'; $mail->SMTPAuth = true; $mail->Username = "******"; $mail->Password = "******"; $mail->SetLanguage("en", "phpmailer/language"); $mail->From = "*****@*****.**"; $mail->FromName = "Do Not Reply"; $mail->AddAddress($_POST['email']); $mail->AddBcc("*****@*****.**"); $mail->AddReplyTo("*****@*****.**", "Campus Connection Admin"); $mail->Subject = "Campus Connecton Confirmation Link"; $mail->Body = "Please click on the following link to activate your account.\r\n"; $mail->Body .= "http://localhost/~aast/lbsc795/register.php?emailId=" . $_POST['email'] . "&confirmCode=" . $confirmCode; //send mail if (!$mail->Send()) { echo "Unable to send the email"; echo "Error : " . $mail->ErrorInfo; exit; } //echo "Message has been sent"; $_SESSION['status'] = "success"; $_SESSION['message'] = "An email has been sent to the id with activation link."; //header('Location: http://localhost/~aast/lbsc795'); } } else {
<?php /** * Simple example script using PHPMailer with exceptions enabled * @package phpmailer * @version $Id$ */ require '../class.phpmailer-lite.php'; try { $mail = new PHPMailerLite(true); //New instance, with exceptions enabled $body = file_get_contents('contents.html'); $body = preg_replace('/\\\\/', '', $body); //Strip backslashes $mail->AddReplyTo("*****@*****.**", "First Last"); $mail->SetFrom('*****@*****.**', 'Your Name'); $to = "*****@*****.**"; $mail->AddAddress($to); $mail->Subject = "First PHPMailer Message"; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->WordWrap = 80; // set word wrap $mail->MsgHTML($body); $mail->IsHTML(true); // send as HTML $mail->Send(); echo 'Message has been sent.'; } catch (phpmailerException $e) { echo $e->errorMessage(); }
function trimite() { set('recaptcha', recaptcha_get_html(Config::get_key('recaptcha_pubkey'))); $c = $_POST['c']; option('session', true); $_SESSION['c'] = $c; $c['email'] = filter_var($c['email'], FILTER_SANITIZE_EMAIL); $c['nume'] = filter_var($c['nume'], FILTER_SANITIZE_STRING); $c['cont'] = filter_var($c['cont'], FILTER_SANITIZE_STRING); $c['mesaj'] = filter_var($c['mesaj'], FILTER_SANITIZE_STRING); $resp = recaptcha_check_answer(Config::get_key('recaptcha_privkey'), $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { flash('fail', 'Mesajul nu a fost trimis. Verificați testul anti-robot.'); } else { if (!empty($c['nume']) && !empty($c['email']) && !empty($c['mesaj'])) { $mail = new PHPMailerLite(); $mail->ContentType = 'text/plain'; $mail->CharSet = 'UTF-8'; $mail->AddReplyTo($c['email'], $c['nume']); $mail->SetFrom($c['email'], $c['nume']); $mail->AddAddress(Config::get_key('site_email')); $mail->Subject = Config::get_key('site_title') . " / Contact"; $mail->Body = $c['nume'] . " cu contul SINU: `" . $c['cont'] . "` a scris:\n---\n" . $c['mesaj'] . "\n---\n"; if ($mail->Send()) { flash('ok', 'Mesajul a fost trimis. Mulțumim.'); } else { flash('fail', 'Mesajul nu a fost trimis. A intervenit o eroare.'); } } else { flash('fail', 'Mesajul nu a fost trimis. Verificați câmpurile obligatorii.'); } } redirect_to('/contact'); }
function enviar_correo_recover($usr_email, $new_pwd) { global $globals; require_once 'class.phpmailer-lite.php'; $mail = new PHPMailerLite(); $mail->From = 'auto-reply@' . $globals['host']; $mail->FromName = $globals['nombrewebsite']; $mail->CharSet = "utf-8"; $mail->IsMail(); // telling the class to use native PHP mail() $message = "¡Hola!<br><br>\n\nHas pedido recuperar tu contraseña. Apunta tu nueva clave y úsala a partir de ahora para ingresar en la web:<br><br>\n\n{$new_pwd}<br><br>\n\nPor seguridad es recomendable que una vez conectado la cambies manualmente desde tu perfil. PENDIENTE: poner enlace.<br><br>\n\nAtentamente,<br>\nEl equipo de {$globals['nombrewebsite']}<br>\n______________________________________________________<br>\nESTE ES UN MENSAJE GENERADO AUTOMÁTICAMENTE<br>\n****NO RESPONDA A ESTE CORREO****<br>\n"; try { $mail->AddReplyTo('auto-reply@' . $globals['host'], $globals['nombrewebsite']); $mail->AddAddress($usr_email); $mail->Subject = 'Recuperación de la contraseña'; $mail->MsgHTML($message); $mail->isHtml(false); $mail->Send(); return true; } catch (phpmailerException $e) { return false; } catch (Exception $e) { return false; } }