if (stripos($value, 'Content-Type:') !== FALSE or $_POST['spam_honeypot'] != '') { $message = "I'm sorry, but there was a problem with your input."; header("Location:contact_result.php?message={$message}&success=0"); exit; } } $email_body = "Name: " . $sender_name . "\n" . "E-mail: " . $sender_email . "\n" . "Message: " . $sender_message; //Send the e-mail. $mail = new PHPmailer(); //$mail->SMTPDebug = 3; $mail->IsSMTP(); $mail->SMTPAuth = true; $mail->SMTPSecure = 'tls'; $mail->Host = "smtp.gmail.com"; $mail->Port = 587; $mail->Username = "******"; $mail->Password = "******"; $mail->From = $sender_email; $mail->FromName = $sender_name; $mail->Body = $email_body; $mail->addAddress("*****@*****.**"); $mail->Subject = "User Commentary"; //Maybe add a new input field to the contact form later? if (!$mail->send()) { $message = "We're sorry, but there was an error in attempting to send your message: " . $mail->ErrorInfo; header("Location:contact_result.php?message={$message}&success=0"); } else { $message = "Thank you! You're message has been sent. We'll get back to you as soon as we are able!"; header("Location:contact_result.php?message={$message}&success=1"); } //header('Refresh: 3;url=index.php');
/** * @param $content */ public function sendMail($content) { $mail = new PHPmailer(); $mail->isSMTP(); $mail->SMTPDebug = 1; $mail->CharSet = 'utf-8'; $mail->Host = 'smtp.163.com'; $mail->SMTPAuth = true; $mail->Username = '******'; $mail->Password = '******'; //$mail->SMTPSecure = false; $mail->Port = 25; $mail->From = '*****@*****.**'; $mail->FromName = '12306提醒'; $mail->addAddress('*****@*****.**'); $mail->isHTML(true); $mail->Subject = '居然还有票~'; $mail->Body = $content . '<br /><br /><br /><a href="https://kyfw.12306.cn/otn/lcxxcx/init">赶紧去12306抢票吧~</a>'; if (!$mail->send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; } else { echo 'Message has been sent'; } }