-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mailto.php
64 lines (53 loc) · 1.38 KB
/
mailto.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
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
$mail = new PHPMailer(TRUE);
$mail1 = $_POST['email'];
$subject1 = "HelpDesk: Contact";
$body1 = $_POST['msg'];
$n = (explode("@",$_POST['email']));
$name1 = $n[0];
try {
$mail->setFrom('', 'HelpDesk');
$mail->addAddress($mail1, $name1);
$mail->AddCC('','HelpDesk');
$mail->Subject = $subject1;
$mail->Body = $body1;
//$mail->addStringAttachment(file_get_contents($pdf_url), 'file.pdf');
//$mail->msgHTML(file_get_contents('contents.html'), __DIR__);
/* SMTP parameters. */
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = TRUE;
$mail->SMTPSecure = 'tls';
$mail->Username = '';
$mail->Password = '';
$mail->Port = 587;
/* Disable some SSL checks. */
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
/* Finally send the mail. */
if (!$mail->send()){
/* PHPMailer error. */
echo $mail->ErrorInfo;
}
else{
echo "<script> alert('mail sent'); window.location.href='index.html';</script>";
}
}
catch (Exception $e)
{
echo $e->errorMessage();
}
catch (\Exception $e)
{
echo $e->getMessage();
}