-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMail.php
41 lines (35 loc) · 1.84 KB
/
Mail.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
<?php
class Mail{
private $senderName;
private $senderEmail;
private $password;
private $SMTPhost;
public function __construct($senderName,$senderEmail,$password,$SMTPhost = 'smtp.gmail.com')
{
require('phpmailer/PHPMailerAutoload.php');
$this->senderName = $senderName;
$this->senderEmail = $senderEmail;
$this->password = $password;
$this->SMTPhost = $SMTPhost;
}
public function sendMail($reciever,$subject = "Test subject",$body = "Test body"){
$mail = new PHPMailer;
$mail->SMTPDebug = 0; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = $this->SMTPhost; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $this->senderEmail; // SMTP username
$mail->Password = $this->password; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom($this->senderEmail, $this->senderName);
$mail->addAddress($reciever); // Add a recipient
$mail->addReplyTo($this->senderEmail);
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AltBody = $body;
$mail->send();
}
}
?>