-
Notifications
You must be signed in to change notification settings - Fork 0
/
class.mail.php
49 lines (42 loc) · 1.23 KB
/
class.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
<?php
class Mail {
private $body = null;
public function setBody($body) {
$this->body = $body;
}
public function send($to, $subject) {
$url = 'https://api.sendgrid.com/';
$user = 'steamdispenser';
$pass = 'Henkie45';
$json_string = array(
'to' => array(
$to
),
'category' => 'Email'
);
$params = array(
'api_user' => $user,
'api_key' => $pass,
'x-smtpapi' => json_encode($json_string),
'to' => $to,
'subject' => "Someone sent you a file! - ".$subject,
'html' => $this->body,
'text' => $this->body,
'from' => '[email protected]',
);
$request = $url.'api/mail.send.json';
$session = curl_init($request);
curl_setopt ($session, CURLOPT_POST, true);
curl_setopt ($session, CURLOPT_POSTFIELDS, $params);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($session, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($session);
if(curl_errno($session)) {
die(CUSTOMERSERVICE);
}
curl_close($session);
return true;
}
}