0% found this document useful (0 votes)
11 views1 page

Practical No. 14

Most Difficult Email Program

Uploaded by

xjarveco
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)
11 views1 page

Practical No. 14

Most Difficult Email Program

Uploaded by

xjarveco
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/ 1

Practical No.

14
Exercise No. 1
<?php
include('smtp/PHPMailerAutoload.php');
$msg = "This is a sample of SMTP Email Service.";
echo smtp_mailer('[email protected]', 'Email Test',
$msg);

function smtp_mailer($to, $subject, $msg){


$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->IsHTML(true);
$mail->CharSet = 'UTF-8';
$mail->SMTPDebug = 0; // Disable debug output
$mail->Username = "[email protected]";
$mail->Password = "yaofvokwlwslgken"; // App Password
$mail->SetFrom("[email protected]");
$mail->Subject = $subject;
$mail->Body = $msg;
$mail->AddAddress($to);
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);

if (!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
return 'Email Sent Successfully!';
}
}
?>

Output:

You might also like