sendmail.php
1.37 KB
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
<?php
require "PHPMailer/PHPMailerAutoload.php";
class SendMail
{
public $to, $body;
private $from, $from_name, $subject;
private $host, $smtp_user, $smtp_password;
public function __construct()
{
$this->from = "noreply@mail-ni-pon.net";
$this->from_name = "め~るNiポン";
$this->subject = "め~るNiポン 自動転送メール";
$this->host = "email-smtp.us-west-2.amazonaws.com";
$this->smtp_user = "AKIA44WSXVI4JODGPXGH";
$this->smtp_password = "BG8I+bxDftyJcQYv2APx1RHWcDN0sQlhm+wXkE5ZQKJb";
}
public function send()
{
$mail = new PHPMailer();
try {
$mail->CharSet = "UTF-8";
$mail->Encoding = "base64";
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Port = 587;
$mail->Host = $this->host;
$mail->Username = $this->smtp_user;
$mail->Password = $this->smtp_password;
$mail->From = $this->from;
$mail->FromName = $this->from_name;
$mail->addAddress($this->to);
$mail->isHTML(true);
$mail->Subject = $this->subject;
$mail->Body = $this->body;
//$mail->addAddress("n.oyamada1219@gmail.com");
//$mail->isHTML(true);
//$mail->Subject = "test";
//$mail->Body = "test";
$mail->Send();
echo "ok";
return true;
} catch (phpmailerException $e) {
echo "ng";
var_dump($e);
return $e;
} catch (Exception $e) {
echo "ng2";
var_dump($e);
return $e;
}
}
}