Menu

[d5ff33]: / examples / example2-SMS.php  Maximize  Restore  History

Download this file

98 lines (79 with data), 2.5 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
/**
*
*
* Version : $Id: newfile.php 2091 2013-01-09 21:45:59Z camiel $
* Copyright : Advanced Mercantile Solutions 2013
* Developer : Camiel de Vleeschauwer
*
This file is part of VodacomMMSSender.
VodacomMMSSender is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Foobar is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with VodacomMMSSender. If not, see <http://www.gnu.org/licenses/>.
**/
require_once '../PHPMailer_5.2.1/class.phpmailer.php';
require_once '../VodacomMMSSender.php';
class MySMSSender extends VodacomEmail2SMSSender
{
const SMTP_HOST = 'localhost';
const SMTP_USER = 'user@somewhere.co.za';
const SMTP_PASSWORD = 'password';
const SMTP_TRANSPORT = 'tls';
const VODACOM_ACCOUNT = 'account';
const VODACOM_ACCOUNT_EMAIL = 'fromaccount@somewhere.co.za';
const VODACOM_GATEWAY_HOST = 'smsgw1.gsm.co.za';
/**
* Constructor initialising parent with Vodacom credentials
*/
public function __construct()
{
$phpMailer = self::configMailer();
parent::__construct($phpMailer,MySMSSender::VODACOM_ACCOUNT, MySMSSender::VODACOM_ACCOUNT_EMAIL,MySMSSender::VODACOM_GATEWAY_HOST);
}
private function configMailer()
{
$phpMailer = new PHPMailer();
$phpMailer->IsSMTP();
$phpMailer->Host = MySMSSender::SMTP_HOST;
$phpMailer->SMTPAuth = true;
$phpMailer->SMTPDebug = true;
$phpMailer->SMTPSecure = MySMSSender::SMTP_TRANSPORT;
$phpMailer->Username = MySMSSender::SMTP_USER;
$phpMailer->Password = MySMSSender::SMTP_PASSWORD;
print "Configured....\n";
return $phpMailer;
}
/**
* Example error retreival function, retrieves the $phpMailer class's error state
*
* @return string
*/
public function getError()
{
return $this->getPhpMailer()->ErrorInfo;
}
}
function main()
{
$sender = new MySMSSender();
$mobileNumbers = array('2783000000','2783000001');
$message = 'SMS Testing from Application Working....';
$result = $sender->sendSMS($mobileNumbers, $message);
if ( $result == true)
{
print "Sent Mail\n";
}
else
{
print "Error Sending mail:" . $sender->getError();
}
}
main();
?>