SametALMDR Posted November 24, 2019 Share Posted November 24, 2019 (edited) Dear All, I tried to send a custom email using PHPMailer but it doesnt work.I run the following codes and the information name surname etc. comes from an form which is in index page. add_hook('ClientAreaPage', 1, function($vars) { $mail = new PHPMailer(true); if(isset($_POST['contact_ex'])){ try { //Server settings $mail->isSMTP(); $mail->Host = 'smtp.gmail.com'; $mail->SMTPAuth = true; $mail->Username = '---'; $mail->Password = '---'; $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; $mail->Port = 587; $mail->CharSet = 'utf-8'; //Recipients $mail->setFrom($_POST['email'], $_POST['namesurname']); $mail->addAddress('example@hotmail.com', '--'); $mail->addReplyTo($_POST['email'], $_POST['namesurname']); // Content $mail->isHTML(true); $mail->Subject = 'Subject'; $mail->Body = 'Some message'; if($mail->send()){ $res = '<div class="alert alert-success" role="alert"> <h5 class="alert-heading">Well done!</h5> <p class="mb-0">Your contact information has been sended successfully!</p> </div>'; }else{ $res = '<div class="alert alert-danger" role="alert"> <h5 class="alert-heading">Oops!</h5> <p class="mb-0">Something went wrong.Please contact with us with phone!</p> </div>'; } } catch (Exception $e) { $res = '<div class="alert alert-danger" role="alert"> <h5 class="alert-heading">Oops!</h5> <p class="mb-0">Something went wrong.Please contact with us with phone!</p> </div>'; } } }); It gives an error about class is not found how can ı create a PHPMailer object.Can you help me @brian! and all of guys ? Edited November 24, 2019 by SametALMDR 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 25, 2019 Share Posted November 25, 2019 17 hours ago, SametALMDR said: Can you help me @brian! and all of guys ? this is more one for Kian - if you search phpmailer and his username, you should find previous example code that he's posted on this topic. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.