Closed rabiatul96 closed 3 years ago
code send email:
`use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception;
include 'PHPMailer/src/Exception.php'; include 'PHPMailer/src/PHPMailer.php'; include 'PHPMailer/src/SMTP.php'; $mail = new PHPMailer(true);try {//Server settings $mail->isSMTP(); $mail->Host = 'smtp.gmail.com'; $mail->SMTPAuth = true; $mail->Username = 'syazwinashahrani@gmail.com' ; $mail->Password = '' ; $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; $mail->Port = 587; $mail->setFrom('syazwinashahrani@gmail.com');// send to one recepient only, name is optional 2nd argument $mail->addAddress($email); $mail->isHTML(true); $mail->Subject = 'KTM SDN BHD' ; $mail->Body = "<p>Hi Mr/Mrs $f_name $l_name,</p> <p>You have successfully purchase KTM ticket from <b>$routes[$origin]</b> to <b>$routes[$destination]</b></p> <p>For more information, please contact management directly.</p> <br> <h4>TICKET - ITINERY</h4> <center> <table border='1'> <tr> <th>From</th> <th>To</th> <th>Category</th> </tr> <tr> <td>$routes[$origin]</td> <td>$routes[$destination]</td> <td>$category</td> </tr> </table> </center> <br> <h4>Passenger details</h4> <table> <tr> <td>Name</td> <td>:</td> <td>$f_name $l_name</td> </tr> <tr> <td>IC Number</td> <td>:</td> <td>$icnum</td> </tr> <tr> <td>Email</td> <td>:</td> <td>$email</td> </tr> </table> <p> Thank You for using KTM.com! </P>" ; $mail->send(); echo "<p>Message has been sent to $email.</p>"; } catch (Exception $e) { echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; } ?>`
code send email:
`use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception;