-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmailer.php
34 lines (31 loc) · 1.06 KB
/
mailer.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
<?php
require 'mailer/Exception.php';
require 'mailer/PHPMailer.php';
require 'mailer/SMTP.php';
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
function send_code_email($email, $code){
$mail = new PHPMailer(true);
try {
//Server settings
$mail->isSMTP();
$mail->Host = 'smtp.mail.ru';
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'password';
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
$mail->Port = 465;
$mail->setFrom('[email protected]', 'MyCoin');
$mail->addAddress($email);
$mail->isHTML(true);
$mail->Subject = 'Код подтверждения - '.$code;
$mail->Body = str_replace('%code%', $code, file_get_contents('../assets/mail.html'));
$mail->AltBody = 'Код подтверждения транзакции MyCoin - '.$code;
$mail->CharSet = "UTF-8";
$mail->send();
} catch (Exception $e) {
return false;
}
return true;
}