Postingan lainnya
Phpmailer tidak bisa connect ke smtp
dapat eror kyk gini,, solusinya gmna ya gan??,, udh aku search di google gk work.. (sengaja untuk passwordnya saya bintangin karna untuk di post)
"2020-08-22 06:11:02 SMTP ERROR: Failed to connect to server: (0)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting"
ini kodenya :
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
use PHPMailer\PHPMailer\SMTP;
//Load composer's autoloader
require 'vendor/autoload.php';
require 'src/PHPMailer.php';
require 'src/SMTP.php';
require 'src/Exception.php';
$mail = new PHPMailer(true);
try {
//Server settings
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Send using SMTP
$mail->Host = 'smtp.gmail.com'; // Set the SMTP server to send through
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'rabildarmawan8@gmail.com'; // SMTP username
$mail->Password = '*******'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
$mail->Port = 465; // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above
//Recipients
$mail->setFrom('rabildarmawan8@gmail.com', 'Rabil Darmawan');
$mail->addAddress("darmawanrabil@gmail.com"); // Add a recipient
$mail->addAddress('darmawanrabil@gmail.com'); // Name is optional
$mail->addReplyTo("darmawanrabil@gmail.com", 'Thank you');
$mail->addCC('darmawanrabil@gmail.com');
$mail->addBCC('darmawanrabil@gmail.com');
// Attachments
// $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
// $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Rabil Darmawan';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
?>
0
1 Jawaban:
<div>Gmailnya sudah di setting buat meng-ON kan less secure apps?<br><br>Disini: https://myaccount.google.com/lesssecureapps?pli=1</div>
0
Tanggapan
Udh aku ON kan
harusnya, kalo sudah di onkan, sudah bisa terkirim dengan baik ya.. mungkin coba ganti port smtpnya menjadi 587..
kmrn menggunakan nodemailer aman jaya sih, cmiiw :P