0% found this document useful (0 votes)
19 views2 pages

Iwd10 B

The document provides a PHP script using the PHPMailer library to send an email via SMTP. It includes configuration details such as the SMTP host, authentication, and email content. The script attempts to send the email and handles any potential errors that may occur during the process.

Uploaded by

vrajc2810
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

Iwd10 B

The document provides a PHP script using the PHPMailer library to send an email via SMTP. It includes configuration details such as the SMTP host, authentication, and email content. The script attempts to send the email and handles any potential errors that may occur during the process.

Uploaded by

vrajc2810
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

IWD 4340704

Practical-10(B)
Aim:- Write a script to send an email.
Source Code:-
<?php

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
require 'PHPMailer-6.9.3/src/Exception.php';
require 'PHPMailer-6.9.3/src/PHPMailer.php';
require 'PHPMailer-6.9.3/src/SMTP.php';

$mail = new PHPMailer(true);


try {

$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'mvno drql obns ahru';
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
$mail->Port = 465;

$mail->setFrom('[email protected]', 'Mailer');

236470307054 99 | P a g e
IWD 4340704
$mail->addAddress('[email protected]', 'Jay');
$mail->isHTML(true);
$mail->Subject = 'Here is the subject';
$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}";
}
?>

Output:

236470307054 100| P a g e

You might also like