Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use PHPMailer\PHPMailer\PHPMailer;
- use PHPMailer\PHPMailer\Exception;
- require 'phpmailer/src/Exception.php';
- require 'phpmailer/src/PHPMailer.php';
- require 'phpmailer/src/SMTP.php';
- date_default_timezone_set('Etc/UTC');
- $mail = new PHPMailer;
- //Tell PHPMailer to use SMTP
- $mail->isSMTP();
- //Enable SMTP debugging
- // 0 = off (for production use)
- // 1 = client messages
- // 2 = client and server messages
- //Set the hostname of the mail server
- $mail->Host = 'smtp.gmail.com';
- // use
- // $mail->Host = gethostbyname('smtp.gmail.com');
- // if your network does not support SMTP over IPv6
- //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
- $mail->Port = 587;
- //Set the encryption system to use - ssl (deprecated) or tls
- $mail->SMTPSecure = 'tls';
- //Whether to use SMTP authentication
- $mail->SMTPAuth = true;
- //Username to use for SMTP authentication - use full email address for gmail
- $mail->Username = "w.r.hasyim@gmail.com";
- //Password to use for SMTP authentication
- $mail->Password = "M1ftahulhuda";
- //Set who the message is to be sent from
- $mail->setFrom('w.r.hasyim@gmail.com', 'Wahyu Rusdiansyah');
- //Set an alternative reply-to address
- $mail->addReplyTo('w.r.hasyim@gmail.com', 'Wahyu Rusdiansyah');
- //Set who the message is to be sent to
- $mail->addAddress('intandesti25@gmail.com', 'intan destiyanti');
- //Set the subject line
- $mail->Subject = 'PHPMailer GMail SMTP test';
- //Replace the plain text body with one created manually
- $mail->Body = 'konek kan akhirnya aseek :v';
- $mail->AltBody = 'This is a plain-text message body';
- //send the message, check for errors
- $mail->send();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement