Net_SMS
[ class tree: Net_SMS ] [ index: Net_SMS ] [ all elements ]

Source for file vodafoneitaly_smtp.php

Documentation is available at vodafoneitaly_smtp.php

  1. <?php
  2. /**
  3.  * Net_SMS_vodafoneitaly_smtp Class implements the SMTP API for accessing the
  4.  * Vodafone Italy SMS gateway. Use of this gateway requires an email account
  5.  * with Vodafone Italy (www.190.it).
  6.  *
  7.  * Copyright 2003-2009 The Horde Project (http://www.horde.org/)
  8.  * Copyright 2003-2007 Matteo Zambelli <mmzambe@hotmail.com>
  9.  *
  10.  * See the enclosed file COPYING for license information (LGPL). If you
  11.  * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
  12.  *
  13.  * $Horde: framework/Net_SMS/SMS/vodafoneitaly_smtp.php,v 1.25 2008/01/02 11:12:11 jan Exp $
  14.  *
  15.  * @author Marko Djukic <marko@oblo.com>
  16.  * @author Matteo Zambelli <mmzambe@hotmail.com>
  17.  * @package Net_SMS
  18.  */
  19.  
  20.     protected $mail;
  21.  
  22.     /**
  23.      * Constructor.
  24.      *
  25.      * @param array $params  Parameters.
  26.      */
  27.     public function __construct($paramsMail $mail)
  28.     {
  29.         parent::__construct($params);
  30.         $this->mail = $mail;
  31.     }
  32.  
  33.     /**
  34.      * An array of capabilities, so that the driver can report which operations
  35.      * it supports and which it doesn't. Possible values are:<pre>
  36.      *   auth        - The gateway require authentication before sending;
  37.      *   batch       - Batch sending is supported;
  38.      *   multi       - Sending of messages to multiple recipients is supported;
  39.      *   receive     - Whether this driver is capable of receiving SMS;
  40.      *   credit      - Is use of the gateway based on credits;
  41.      *   addressbook - Are gateway addressbooks supported;
  42.      *   lists       - Gateway support for distribution lists.
  43.      * </pre>
  44.      *
  45.      * @var array 
  46.      */
  47.     var $capabilities = array('auth'        => false,
  48.                               'batch'       => false,
  49.                               'multi'       => false,
  50.                               'receive'     => false,
  51.                               'credit'      => false,
  52.                               'addressbook' => false,
  53.                               'lists'       => false);
  54.  
  55.     /**
  56.      * This function does the actual sending of the message.
  57.      *
  58.      * @access private
  59.      *
  60.      * @param array $message  The array containing the message and its send
  61.      *                         parameters.
  62.      * @param string $to      The recipient.
  63.      *
  64.      * @return array  An array with the success status and additional
  65.      *                 information.
  66.      */
  67.     protected function _send($message$to)
  68.     {
  69.         /* Since this only works for Italian numbers, this is hardcoded. */
  70.         if (preg_match('/^.*?<?(\+?39)?(\d{10})>?/'$to$matches)) {
  71.             $headers['From'$this->_params['user'];
  72.             $to $matches[2'@sms.vodafone.it';
  73.  
  74.             $result $this->mail->send($to$headers$message['text']);
  75.             if (is_a($result'PEAR_Error')) {
  76.                 return array(0$result->getMessage());
  77.             else {
  78.                 return array(1null);
  79.             }
  80.         else {
  81.             return array(0_("You need to provide an Italian phone number"));
  82.         }
  83.     }
  84.  
  85.     /**
  86.      * Identifies this gateway driver and returns a brief description.
  87.      *
  88.      * @return array  Array of driver info.
  89.      */
  90.     function getInfo()
  91.     {
  92.         return array(
  93.             'name' => _("Vodafone Italy via SMTP"),
  94.             'desc' => _("This driver allows sending of messages via SMTP through the Vodafone Italy gateway, only to Vodafone numbers. It requires an email account with Vodafone Italy (http://www.190.it)."),
  95.         );
  96.     }
  97.  
  98.     /**
  99.      * Returns the required parameters for this gateway driver.
  100.      *
  101.      * @return array  Array of required parameters.
  102.      */
  103.     function getParams()
  104.     {
  105.         return array('user' => array('label' => _("Username"),
  106.                                      'type' => 'text'));
  107.     }
  108.  
  109.     /**
  110.      * Returns the parameters that can be set as default for sending messages
  111.      * using this gateway driver and displayed when sending messages.
  112.      *
  113.      * @return array  Array of parameters that can be set as default.
  114.      */
  115.     function getDefaultSendParams()
  116.     {
  117.         return array();
  118.     }
  119.  
  120.     /**
  121.      * Returns the parameters for sending messages using this gateway driver,
  122.      * displayed when sending messages. These are filtered out using the
  123.      * default values set up when creating the gateway.
  124.      *
  125.      * @return array  Array of required parameters.
  126.      * @todo  Would be nice to use a time/date setup rather than minutes from
  127.      *         now for the delivery time. Upload field for ringtones/logos?
  128.      */
  129.     function getSendParams($params)
  130.     {
  131.         return array();
  132.     }
  133.  
  134.  
  135.  
  136. }

Documentation generated on Mon, 11 Mar 2019 15:57:16 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.