-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsendemail.php
46 lines (36 loc) · 1.24 KB
/
sendemail.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
<?php
use PHPMailer\PHPMailer\PHPMailer;
require_once 'phpmailer/Exception.php';
require_once 'phpmailer/PHPMailer.php';
require_once 'phpmailer/SMTP.php';
$alert='';
$mail = new PHPMailer(true);
if(isset($_POST['submit'])){
$Name = $_POST['name'];
$Email = $_POST['email'];
$msg = $_POST['message'];
try{
$mail -> isSMTP();
$mail-> Host = 'smtp.gmail.com';
$mail-> SMTPAuth = true;
$mail-> Username = 'youemailid'; //enter your email id
$mail-> Password = 'yourpassword'; //enter your password
$mail->SMTPSecure=PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = '587';
$mail-> setFrom('youemailid'); //enter your email id of admin 1
$mail->addAddress('youemailid'); //enter your email id of admin 2
$mail->addAddress('youemailid'); //enter your email id of admin 3
$mail->isHTML(true);
$mail->Subject='Message Received (Contact Page)';
$mail-> Body ="<h3>Name : $Name <br> Email : $Email <br> Message: $msg</h3>";
$mail->send();
$alert='<div class="alert-sucess>
<span>Message Sent! Thankyou for contacting us.</span>
</div>';
}catch(Exception $e){
$alert='<div class="alert-error">
<span>'.$e->getMessage().'</span>
</div>';
}
}
?>