SMTPDebug = SMTP::DEBUG_SERVER; // for detailed debug output $mail->isSMTP(); $mail->Host = 'smtp.gmail.com'; $mail->SMTPAuth = true; $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; $mail->Port = 587; $mail->Username = 'muhdkhairulamin@gmail.com'; // YOUR gmail email $mail->Password = 'Muhd_279264'; // YOUR gmail password // Sender and recipient settings++g $mail->setFrom('muhdkhairulamin@gmail.com', 'Khairul'); $mail->addAddress('muhdkhairulamin@gmail.com', 'Test'); // Setting the email content $mail->IsHTML(true); $mail->Subject = "Website Contact Form"; $mail->Body = 'Name : '. $name .'
Email : '. $email .'
Message : '. $message .' '; $mail->AltBody = 'Plain text message body for non-HTML email client. Gmail SMTP email body.'; $mail->send(); echo "Email message sent."; } catch (Exception $e) { echo "Error in sending email. Mailer Error: {$mail->ErrorInfo}"; } ?>