-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmailer.php
37 lines (35 loc) · 1.16 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
35
36
37
<?
require 'lib/phpMailerAutoload.php';
if(isset($_POST['email'])){
$email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
$css = $_POST['css'];
$html = $_POST['html'];
ob_start();
include 'code_tmpl.php';
$tmpl = ob_get_clean();
if(!$email){
echo json_encode(array('status' => 'error', 'msg' => 'Bad email')); exit();
}
$send = email($email, 'Your button from css3 button generator', $tmpl, $file);
if($send){
echo json_encode(array('status' => 'ok!', 'msg' => 'Mail success sended!'));exit();
}else{
echo json_encode(array('status' => 'error', 'msg' => 'Mail don\'t delivered')); exit();
}
}
function email($email, $subject, $text, $file){
$mail = new PHPMailer;
$mail->From = '[email protected]';
$mail->FromName = 'css 3 button generator';
$mail->addAddress($email);
$mail->isHTML(true);
$mail->addAttachment('tmp/' . $file);
$mail->Subject = $subject;
$mail->Body = $text;
$mail->AltBody = 'HTML и CSS вашей кнопки в прикрипленном файле';
$res = $mail->send();
@unlink('tmp/' . $file);
return $res;
}
?>
?>