-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmail.php
executable file
·69 lines (54 loc) · 2.37 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
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
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'phpmailer/Exception.php';
require 'phpmailer/PHPMailer.php';
require 'phpmailer/SMTP.php';
if($_POST['name'] && $_POST['email'] && $_POST['address'] && $_POST['description']) {
$subject='Contactus from > '.$_POST['name'];
$message='Name : '.$_POST['name'].' Email : '.$_POST['email'].' Address : '.$_POST['address'].' Description : '.$_POST['description'];
$from=$_POST['email'];
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.mailgun.org'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = '8eg3pmpv9d-8'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable encryption, only 'tls' is accepted
$mail->From = $from;
$mail->FromName = $from;
$mail->addAddress('[email protected]');
$mail->Subject = $subject;
$mail->Body =$message;
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
} else if($_POST['subscriber']){
$subject='Subscriber from > '.$_POST['subscriber'];
$message='Subscriber : '.$_POST['subscriber'];
$from=$_POST['subscriber'];
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.mailgun.org'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = '8eg3pmpv9d-8'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable encryption, only 'tls' is accepted
$mail->From = $from;
$mail->FromName = $from;
// $mail->addAddress('[email protected]');
$mail->Subject = $subject;
$mail->Body =$message;
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
} else {
die("Error Email Parameter !");
}
?>