-
Notifications
You must be signed in to change notification settings - Fork 0
/
email-script.php
35 lines (33 loc) · 1.33 KB
/
email-script.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
<?php
if (isset($_POST['sendMailBtn'])) {
$fromEmail = $_POST['fromEmail'];
$toEmail = $_POST['toEmail'];
$subjectName = $_POST['subject'];
$message = $_POST['message'];
$to = $toEmail;
$subject = $subjectName;
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: '.$fromEmail.'<'.$fromEmail.'>' . "\r\n".'Reply-To: '.$fromEmail."\r\n" . 'X-Mailer: PHP/' . phpversion();
$message = '<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<span class="preheader" style="color: transparent; display: none; height: 0; max-height: 0; max-width: 0; opacity: 0; overflow: hidden; mso-hide: all; visibility: hidden; width: 0;">'.$message.'</span>
<div class="container">
'.$message.'<br/>
Regards<br/>
'.$fromEmail.'
</div>
</body>
</html>';
$result = @mail($to, $subject, $message, $headers);
echo '<script>alert("Email sent successfully !")</script>';
echo '<script>window.location.href="index.php";</script>';
}