-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendEmail.php
64 lines (28 loc) · 1.63 KB
/
sendEmail.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
// create object of PHPMailer class with boolean parameter which sets/unsets exception.
$mail = new PHPMailer(true);
try {
$mail->isSMTP(); // using SMTP protocol
$mail->Host = 'ssl://smtp.gmail.com'; // SMTP host as gmail
$mail->SMTPAuth = true; // enable smtp authentication
$mail->Username = '[email protected]'; // sender gmail host
$mail->Password = 'ihztsijwheggbfmy'; // sender gmail host password
$mail->SMTPSecure = 'tls'; // for encrypted connection
$mail->Port = 465; // port for SMTP
$mail->isHTML(true);
$mail->setFrom('[email protected]', "Sender"); // sender's email and name
$mail->addAddress("[email protected]", "HADIJAMAN"); // receiver's email and name
$headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$mail->Subject = 'Email verification From Codemanbd';
$mail->Body = "Love Codemanbd";
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) { // handle error.
echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}
?>