SMTP -> DARI SERVER. 220 smtp. gmail. com ESMTP p5-20020a170902bd0500b001932a9e4f2csm11204063pls. 255 - gsmtp SMTP -> DARI SERVER. 250-smtp. gmail. com siap melayani Anda, [119. 59. 120. 34] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 SMTP -> KESALAHAN. Kata sandi tidak diterima dari server. 535-5. 7. 8 Username dan Password tidak diterima. Pelajari lebih lanjut di 535 5. 7. 8 https. //dukung. google. com/mail/?p=BadCredentials p5-20020a170902bd0500b001932a9e4f2csm11204063pls. 255 - gsmtp SMTP -> DARI SERVER. 250 2. 1. 5 Siram p5-20020a170902bd0500b001932a9e4f2csm11204063pls. 255 - gsmtp Kesalahan SMTP. Tidak dapat mengautentikasi PHPMailer adalah perpustakaan PHP yang memiliki fungsi bawaan untuk mengirim email dengan aman dan mudah menggunakan PHP dari server Show Mail adalah fungsi yang berguna di situs web Ini digunakan untuk verifikasi pengguna, lupa kata sandi, mengirim informasi, dll Dalam tutorial ini, saya menunjukkan bagaimana Anda mengirim email menggunakan server SMTP dengan PHPmailer di PHP Unduh Isi1. PHPMailer
composer require phpmailer/phpmailer
2. Dapatkan Detail SMTP
3. PHPImpor <?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; // Load Composer's autoloader require 'vendor/autoload.php';_2, <?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; // Load Composer's autoloader require 'vendor/autoload.php';3 kelas dan sertakan <?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; // Load Composer's autoloader require 'vendor/autoload.php';4 <?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; // Load Composer's autoloader require 'vendor/autoload.php';_ Buat objek <?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; // Load Composer's autoloader require 'vendor/autoload.php';_2 // Instantiation and passing `true` enables exceptions $mail = new PHPMailer(true);_ Tetapkan 0 hingga <?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; // Load Composer's autoloader require 'vendor/autoload.php';_6 untuk menonaktifkan proses debug. Untuk mengaktifkan pass 2 $mail->SMTPDebug = 0; // 0 - Disable Debugging, 2 - Responses received from the server Tentukan host server di <?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; // Load Composer's autoloader require 'vendor/autoload.php';_7, nama pengguna di <?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; // Load Composer's autoloader require 'vendor/autoload.php';8, dan kata sandi di <?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; // Load Composer's autoloader require 'vendor/autoload.php';9. Tetapkan // Instantiation and passing `true` enables exceptions $mail = new PHPMailer(true);0 di // Instantiation and passing `true` enables exceptions $mail = new PHPMailer(true);1 dan // Instantiation and passing `true` enables exceptions $mail = new PHPMailer(true);2 ke // Instantiation and passing `true` enables exceptions $mail = new PHPMailer(true);3
$mail->Host = 'mail.makitweb.com'; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = '[email protected]'; // SMTP username $mail->Password = 'password'; // SMTP password $mail->SMTPSecure = 'tls';//PHPMailer::ENCRYPTION_STARTTLS; Enable TLS encryption, `PHPMailer::ENCRYPTION_SMTPS` also accepted $mail->Port = 587; // TCP port to connect to Tentukan id email dan nama pengirim di // Instantiation and passing `true` enables exceptions $mail = new PHPMailer(true);4 dan id email penerima dan nama di // Instantiation and passing `true` enables exceptions $mail = new PHPMailer(true);5 $mail->setFrom('[email protected]', 'Yogesh singh'); $mail->addAddress('Recipient email-id', 'Recipient name'); // Add a recipient Tentukan subjek email, dan badan di // Instantiation and passing `true` enables exceptions $mail = new PHPMailer(true);6, // Instantiation and passing `true` enables exceptions $mail = new PHPMailer(true);7, dan // Instantiation and passing `true` enables exceptions $mail = new PHPMailer(true);8 $mail->isHTML(true); // Set email format to HTML $mail->Subject = 'Send email using SMTP with PHPmailer'; $mail->Body = 'A test email from <a href="https://makitweb.com">maktiweb.com</a>'; $mail->AltBody = 'A test email from makitweb.com'; // Plain text for non-HTML mail clients Lampirkan file menggunakan metode // Instantiation and passing `true` enables exceptions $mail = new PHPMailer(true);_9. Anda dapat menentukan nama file menggunakan parameter ke-2 $mail->addAttachment('upload/file.pdf'); $mail->addAttachment('upload/image.png', 'image 1'); // Optional name Hubungi $mail->SMTPDebug = 0; // 0 - Disable Debugging, 2 - Responses received from the server_0 untuk mengirim permintaan Kode Selesai <?php // Import PHPMailer classes into the global namespace // These must be at the top of your script, not inside a function use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; // Load Composer's autoloader require 'vendor/autoload.php'; // Instantiation and passing `true` enables exceptions $mail = new PHPMailer(true); try { //Server settings $mail->SMTPDebug = 0; // 0 - Disable Debugging, 2 - Responses received from the server $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'mail.makitweb.com'; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = '[email protected]'; // SMTP username $mail->Password = 'password'; // SMTP password $mail->SMTPSecure = 'tls';//PHPMailer::ENCRYPTION_STARTTLS; Enable TLS encryption, `PHPMailer::ENCRYPTION_SMTPS` also accepted $mail->Port = 587; // TCP port to connect to //Recipients $mail->setFrom('[email protected]', 'Yogesh singh'); $mail->addAddress('Recipient email-id', 'Recipient name'); // Add a recipient // Content $mail->isHTML(true); // Set email format to HTML $mail->Subject = 'Send email using SMTP with PHPmailer'; $mail->Body = 'A test email from <a href="https://makitweb.com">maktiweb.com</a>'; $mail->AltBody = 'A test email from makitweb.com'; // Plain text for non-HTML mail clients // Attachement $mail->addAttachment('upload/file.pdf'); $mail->addAttachment('upload/image.png', 'image 1'); // Optional name $mail->send(); echo 'Message has been sent'; } catch (Exception $e) { echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; } 4. KesimpulanDapatkan detail SMTP dari cPanel jika Anda tidak memilikinya dan gunakan untuk mengonfigurasi PHPMailer. Aktifkan debugging dengan menetapkan 2 ke <?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; // Load Composer's autoloader require 'vendor/autoload.php';6 jika mendapatkan masalah saat mengirim email Bagaimana cara mengatur PHPMailer?Menginstal PHPMailer . Masuk ke server Anda melalui SSH Pastikan Anda berada di direktori home pengguna Anda. [server]$ cd ~ Buka zip file. [server]$ unzip master. zip. Ini membuat direktori bernama PHPMailer-master Ganti nama direktori ini. [server]$ mv PHPMailer-master PHPMailer Bagaimana cara menggunakan PHPMailer?Muat pemuat otomatis komposer. memerlukan 'vendor/autoload. php'; . . isHTML(). Jika benar, setel format email ke HTML Subjek. Tetapkan subjek Surat Tubuh. Mengatur isi Mail Badan Alt. Badan alternatif jika klien email tidak mendukung HTML Apakah aman menggunakan PHPMailer?Semua yang dikatakan, tentu saja PHPMailer (seperti perpustakaan teknis lainnya) dapat disalahgunakan untuk mengirim semua jenis phishing, spam, dan malware jahat, dan kelas SMTP dapat digunakan untuk mencoba mengacaukan server email, meskipun itu akan mencoba
Bagaimana saya tahu jika PHPMailer berfungsi?untuk memeriksa apakah mengirim email sebagaimana dimaksud; . com"; $subject = "Email Test"; $message = "ini adalah fungsi email testing email di server"; $sendMail = mail($email, $subject, $message); if($sendMail) { echo "Email Sent Successfully"; } else { echo "Mail Failed"; } ?> |