emcuriah Posted March 31, 2022 Share Posted March 31, 2022 Hello, thanks for opening this first and foremost. So i've been designing a website for myself here . On the last page is a contact form that i've been trying to figure out. This was a html web template that i had purchased and replaced with my own info, pics etc. everything is fully functional but i cannot figure out how to set up my handler.php file to route the contact form back to my gmail. The only directions on the contact form was to "refer to handler.php". I have attached a copy of that file, I think i have filled out the information correctly but still has error submitting contact form after uploading to aws. I'm really new to html or php, just trying to self teach myself but i havent been able to solute it with any research i've been looking up. Any guidance or info to where i might be going left is beyond appreciated. Bless, -MC ------------ <?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; require 'file:///SSD/Users/mc/Documents/sites/elements-mikael-modern-creative-cvresume-template-28H8B9D-R78y6RFN-06-06/Mikael HTML/php/PHPMailer-5.2.28/src/Exception.php'; require 'file:///SSD/Users/mc/Documents/sites/elements-mikael-modern-creative-cvresume-template-28H8B9D-R78y6RFN-06-06/Mikael HTML/php/PHPMailer-5.2.28/src/PHPMailer.php'; require 'file:///SSD/Users/mc/Documents/sites/elements-mikael-modern-creative-cvresume-template-28H8B9D-R78y6RFN-06-06/Mikael HTML/php/PHPMailer-5.2.28/src/SMTP.php'; $mail = new PHPMailer(true); $mail_subject = 'Subject'; $mail_to_email = 'emcuriah@gmail.com'; // your email $mail_to_name = 'Webmaster'; try { $mail_from_name = isset( $_POST['name'] ) ? $_POST['name'] : ''; $mail_from_email = isset( $_POST['email'] ) ? $_POST['email'] : ''; $mail_category = isset( $_POST['category'] ) ? $_POST['category'] : ''; $mail_budget = isset( $_POST['budget'] ) ? $_POST['budget'] : ''; $mail_message = isset( $_POST['message'] ) ? $_POST['message'] : ''; // Server settings $mail->isSMTP(); // Send using SMTP $mail->Host = 'smtp.gmail.com'; // Set the SMTP server to send through $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = 'emcuriah@gmail.com'; // SMTP username $mail->Password = '...'; // SMTP password $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged $mail->Port = 465; // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above $mail->setFrom($mail_to_email, $mail_to_name); // Your email $mail->addAddress($mail_from_email, $mail_from_name); // Add a recipient // for($ct=0; $ct<count($_FILES['file_attach']['tmp_name']); $ct++) { // $mail->AddAttachment($_FILES['file_attach']['tmp_name'][$ct], $_FILES['file_attach']['name'][$ct]); // } // Content $mail->isHTML(true); // Set email format to HTML $mail->Subject = $mail_subject; $mail->Body = ' <strong>Name:</strong> ' . $mail_from_name . '<br> <strong>Email:</strong> ' . $mail_from_email . '<br> <strong>Category:</strong> ' . $mail_category . '<br> <strong>Budget:</strong> ' . $mail_budget . '<br> <strong>Message:</strong> ' . $mail_message; $mail->Send(); echo 'Message has been sent!'; } catch (Exception $e) { echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; } Quote Link to comment https://forums.phpfreaks.com/topic/314647-i-cant-figure-out-what-im-doing-wrong-for-the-life-of-me-phpsmtp/ Share on other sites More sharing options...
requinix Posted March 31, 2022 Share Posted March 31, 2022 If there's an error then it would help to know what that error says... Quote Link to comment https://forums.phpfreaks.com/topic/314647-i-cant-figure-out-what-im-doing-wrong-for-the-life-of-me-phpsmtp/#findComment-1594760 Share on other sites More sharing options...
gizmola Posted April 1, 2022 Share Posted April 1, 2022 These type of contact pages don't work very well for a number of reasons, most notably that bots fill your inbox with spam. This particular script can also be exploited by anyone (and again mostly it will be bots) to send email from your account, via this line: $mail->addAddress($mail_from_email, $mail_from_name); // Add a recipient I can spam your form, put a bunch of porn site links in the body, and have my from address be some person I want to spam with those links, and your gmail will send them a copy of the email. That line should be commented out at very least. As Req already noted, we need some debugging information, because we have no idea at what point where the script fails. Quote Link to comment https://forums.phpfreaks.com/topic/314647-i-cant-figure-out-what-im-doing-wrong-for-the-life-of-me-phpsmtp/#findComment-1594792 Share on other sites More sharing options...
gizmola Posted April 1, 2022 Share Posted April 1, 2022 Almost forgot to say that I edited your original post because it appeared to contain your actual gmail password. I would change your gmail password ASAP if it actually was the real one. Quote Link to comment https://forums.phpfreaks.com/topic/314647-i-cant-figure-out-what-im-doing-wrong-for-the-life-of-me-phpsmtp/#findComment-1594793 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.