1

I need help with my PHP code. So what I am doing is a suggestion box where all suggestions are going to be sent to my email. I am using PHPmailer. However, whenever I try to send a suggestion on the box I made it won't send to my email instead it echoes the else code I made for errors. I am not sure what is wrong with my code.

if (empty($errors)) {
    $m =  new PHPMailer;

    $m->SMPTDebug =1;

    $m->isSMTP();
    $m->isSMTPAuth = true;

    $m->Host = 'smpt.mail.yahoo.com';
    $m->Username = 'blahblah@yahoo.com.sg';
    $m->Password = 'blahbalh';
    $m->SMTPSecure = 'tls';
    $m->Port = '587';

    $m->isHTML();

    $m->Subject = 'Contact from submitted';
    $m->Body = 'From: '.$fields['name'].' ('.$fields['email'].')<p>'.$fields['text'].'</p>';

    $m->FromName = 'Contact';

    $m->AddReplyTo($fields['email'], $fields['name']);

    $m->AddAddress('blahblah@yahoo.com.sg', 'Bl Ah');

    if ($m->send()) {
        header('Location: trial_contact_thankyou.php');
        die();
    }
    else {
        $errors[] = 'Sorry, could not send email. Please try again later';
    }

Thank you for those who will help!

  • Have a look here: http://stackoverflow.com/questions/2386544/error-handling-with-phpmailer ; PHPMailer error handling explained in the first answer – Tom Regner Nov 20 '15 at 08:03

0 Answers0