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

Documentation generated on Mon, 11 Mar 2019 14:39:04 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.