source: pro-bachkim-filespace/sourcecode/api.violet.vn/www/lib/common/myMail.class.php @ 105

Last change on this file since 105 was 19, checked in by dungnv, 11 years ago
File size: 1.4 KB
Line 
1<?php
2
3class myMail {
4 
5  public $setFrom;
6  public $From;
7  public $FromName;
8  public $To;
9  public $ToName;
10  public $Subject;
11  public $Body;
12  public $ReplyTo;
13 
14  public function __construct() {
15    $this->setFrom('hotro@violet.vn', 'Thu vien Violet');
16  }
17
18  public function setFrom($address, $name = null) {
19    $this->From = $address;
20    $this->FromName = $name;
21  }
22
23  public function addAddress($address, $name = null) {
24    $this->To = $address;
25    $this->ToName = $name;
26  }
27
28  public function addReplyTo($address, $name = null) {
29    $this->ReplyTo = $address;
30  }
31
32  public function setSubject($subject) {
33    $this->Subject = $subject;
34  }
35
36  public function setBody($body) {
37    $this->Body = $body;
38  }
39
40  public function send() {
41    $url = 'http://54.254.211.41';
42    $postData = array();
43    $postData['from'] = $this->From;
44    $postData['fromname'] = $this->FromName;
45    $postData['replyto'] = $this->ReplyTo;
46    $postData['to'] = $this->To;
47    $postData['toname'] = $this->ToName;
48    $postData['subject'] = $this->Subject;
49    $postData['content'] = $this->Body;
50    $ch = curl_init();
51    curl_setopt($ch, CURLOPT_URL, $url);
52    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
53    curl_setopt($ch, CURLOPT_POST, 1);
54    curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
55    $result = curl_exec($ch);
56    curl_close($ch);
57    myUtility::log($this->ToName.' <'.$this->To.'> "'.$this->Subject.'"', 'mail.log');
58    return $result=='true';
59  }
60}
Note: See TracBrowser for help on using the repository browser.