-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsendmail.php
More file actions
100 lines (90 loc) · 2.5 KB
/
Copy pathsendmail.php
File metadata and controls
100 lines (90 loc) · 2.5 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'mailer/Exception.php';
require 'mailer/PHPMailer.php';
require 'mailer/SMTP.php';
require 'mailer/POP3.php';
require 'mailer/OAuth.php';
function sendmaiil($recipent_id,$recipent_name,$body,$sub){
$mail = new PHPMailer(true); // Passing `true` enables exceptions
try {
//Server settings
$mail->SMTPDebug = 0;
$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 = 'yashwantsoni009@gmail.com'; // SMTP username
$mail->Password = '*********'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption
$mail->Port = 587; // TCP port to connect to
//Recipients
$mail->setFrom('yashwantsoni009@gmail.com', 'Yashwant');
$mail->addAddress($recipent_id,$recipent_name);
$mail->addReplyTo('yashwantsoni009@gmail.com', 'Yashwant');
$mail->isHTML(true);
$mail->Subject = $sub;
$mail->Body = '<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
h1{
text-align: center;background-color: #2F2C2C;color:white;font-weight: 100;
display: inline-block;
padding-right: 15px;
padding-left: 15px;
border-radius: 5px;
}
div{
background-color: #F4F8FF;
width: 600px;
margin: auto;
padding: 20px;
}
a{
/*text-decoration: none;*/
text-align: justify;
}
p{
line-height: 20px;
letter-spacing: 1.1px;
font-family: arial;
font-size: 0.9em;
}
blockquote{
/*text-align:center;*/
font-family: verdana;
font-weight: 100%;
}
section{
width:400px;
margin:auto;
}
span{
font-weight:bold;
}
</style>
</head>
<body>
<div>
<p>Hi '.$recipent_name.',</p><p>
'.$body.'</p>
<p>Warm Regards,</p>
<p>Yashwant Soni</p>
</div>
</body>
</html>';
$mail->AltBody = $body;
$mail->send();
echo 'mail has been sent';
echo '<br>';
} catch (Exception $e) {
echo 'Mail could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
echo '<br>';
}
}
$body="testing";
sendmaiil($email,$name,$body,$sub);
?>