Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require 'PHPMailer/PHPMailerAutoload.php';
- $mail = new PHPMailer;
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'ghapto98@gmail.com'; // SMTP username
- $mail->Password = 'anyspeatat11'; // SMTP password
- $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = 587; // TCP port to connect to
- $mail->setFrom('info@codexworld.com', 'CodexWorld');
- $mail->addReplyTo('info@codexworld.com', 'CodexWorld');
- $mail->addAddress('ghapto98@gmail.com'); // Add a recipient
- $mail->addCC('cc@example.com');
- $mail->addBCC('bcc@example.com');
- $mail->isHTML(true); // Set email format to HTML
- $bodyContent = '<h1>How to Send Email using PHP in Localhost by CodexWorld</h1>';
- $bodyContent .= '<p>This is the HTML email sent from localhost using PHP script by <b>CodexWorld</b></p>';
- $mail->Subject = 'Email from Localhost by CodexWorld';
- $mail->Body = $bodyContent;
- if(!$mail->send()) {
- echo 'Message could not be sent.';
- echo 'Mailer Error: ' . $mail->ErrorInfo;
- } else {
- echo 'Message has been sent';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement