soupi Posted October 10, 2018 Share Posted October 10, 2018 Hi there, I'm supporting a webmaster at godaddy and we are using PHPMailer in a PHP script which is kind of a contact form. Error reporting of PHP is switched on and the script is running without errors and the send function of PHPMailer is returning true, i. e. success. However the mail doesn't arrive at the recipient. I tested the same script at my own webspace which is hosted by the german all-inkl and it's working fine there. This is the script: <?php // add PHP Mailer use PHPMailer\PHPMailer\PHPMailer; require_once 'phpmailer/src/Exception.php'; require_once 'phpmailer/src/PHPMailer.php'; const HTML_ERROR_START = '<div class="alert alert-danger" role="alert"><p class="m-0">'; const HTML_ERROR_END = '</p></div>'; const HTML_SUCCESS_START = '<div class="alert alert-success" role="alert"><p class="m-0">'; const HTML_SUCCESS_END = '</p></div>'; $receiver = 'name@domain.tld'; $emailfrom = 'name@Yahoo.com'; $namefrom = 'Contact Form'; /** * 1. Check if form was submitted. */ if (isset($_POST['submit'])) { /** * 2. Filter data * - We use the function htmlspecialchars() * - The function trim() is used to remove all empty spaces from start and end of the string */ $choice = htmlspecialchars(trim($_POST['choice-animals'])); $persons = []; for ($i = 1;isset($_POST['dyninput' . $i]); $i++) { $persons[] = htmlspecialchars(trim($_POST['dyninput' . $i])); } $familyname = htmlspecialchars(trim($_POST['family-name'])); $comments = htmlspecialchars(trim($_POST['paragraph_text'])); $errors = []; $success = false; $nr = 1; foreach ($persons as $cperson) { if (empty($cperson)) { $errors[] = HTML_ERROR_START . 'Please enter a name for person no. ' . $nr . ' !' . HTML_ERROR_END; $nr++; } } if (empty($familyname)) { $errors[] = HTML_ERROR_START . 'Please enter a family name!' . HTML_ERROR_END; } /** * 4. Check if there were errors, if not send email * - for sending email we use PHPMailer */ if (count($errors) === 0) { $mailer = new PHPMailer(); $mailer->CharSet = 'UTF-8'; // Set charset setzen for correct display of special characters $mailer->setFrom($emailfrom, $namefrom); // Set email address and name of sender $mailer->addAddress($receiver); // Empfängeradresse $mailer->isHTML(true); $mailer->Subject = 'New message'; // Subject $mailer->Body = '<h3>New message</h3> <h3>Choice was: ' . $choice . '</h3> <h3>Family name was: ' . $familyname . '</h3> <h2>Persons:</h2>'; foreach ($persons as $cperson) { $mailer->Body .= $cperson . '<br>'; } $mailer->Body .= '<h2>Comments were:</h2>'; $mailer->Body .= $comments; /** * Check if email was sent successfully * if so: Report success * if not: Report error(s) */ if (!$mailer->send()) { $errors[] = HTML_ERROR_START . 'An errror occured. Please try again in some minutes!' . HTML_ERROR_END; } else { $success = HTML_SUCCESS_START . 'Your Message was sent successfully!' . HTML_SUCCESS_END; } } } I checked several other discussions regarding this issue but didn't find a solution. Any hints are welcome. Quote Link to comment Share on other sites More sharing options...
requinix Posted October 10, 2018 Share Posted October 10, 2018 Debug this from the mailing standpoint first. How are mails being sent locally? How is sendmail configured? Are mails going into a queue? Being sent? Any bounces? Does the email get sent but end up triggering spam filters? Quote Link to comment Share on other sites More sharing options...
gizmola Posted October 10, 2018 Share Posted October 10, 2018 GoDaddy hosting is not known for its quality. With that said, I would check out this thread on solving issues with configuration and phpmailer. Quote Link to comment Share on other sites More sharing options...
soupi Posted October 10, 2018 Author Share Posted October 10, 2018 I changed it to this, and no luck... wedding@rahmankhaliq.com is created through go daddy <?php // add PHP Mailer use PHPMailer\PHPMailer\PHPMailer; require_once 'phpmailer/src/Exception.php'; require_once 'phpmailer/src/PHPMailer.php'; const HTML_ERROR_START = '<div class="alert alert-danger" role="alert"><p class="m-0">'; const HTML_ERROR_END = '</p></div>'; const HTML_SUCCESS_START = '<div class="alert alert-success" role="alert"><p class="m-0">'; const HTML_SUCCESS_END = '</p></div>'; $receiver = 'harahman@syr.edu'; $emailfrom = 'wedding@rahmankhaliq.com'; $namefrom = 'Contact Form'; 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.