PHP MAILER

  • Post
    admin
    Keymaster

    // Redirect immediately (faster UX)
    header(“Location: $THANK_YOU”);
    header(“Connection: close”);
    if (ob_get_level()) {
    ob_end_flush();
    }
    flush();

    // ———- PHPMailer SMTP ———-
    require __DIR__ . ‘/PHPMailer/Exception.php’;
    require __DIR__ . ‘/PHPMailer/PHPMailer.php’;
    require __DIR__ . ‘/PHPMailer/SMTP.php’;

    try {
    $mail = new \PHPMailer\PHPMailer\PHPMailer(true);

    $mail->isSMTP();
    $mail->Host = ‘mail.yourdomain.com’;
    $mail->SMTPAuth = true;
    $mail->Username = ‘your-user-name’;
    $mail->Password = ‘you-password’;
    $mail->SMTPSecure = ‘ssl’;
    $mail->Port = 465;

    $mail->setFrom(‘your-email’, ‘your company name’);
    $mail->addReplyTo($data[’email’], $data[‘name’]);
    $mail->addAddress(‘your-email’);

    $mail->Subject = ‘New Quote Request’;
    $mail->Body = $message;

    $mail->send();

    } catch (\PHPMailer\PHPMailer\Exception $e) {
    @mail(
    $TO_EMAIL,
    “New Quote Request”,
    $message,
    “From: your-email-from-address\r\nReply-To: {$data[’email’]}”
    );
    }

    • This topic was modified 2 weeks, 3 days ago by admin.
  • You must be logged in to reply to this topic.