sms_fast2sms
5 sites
Security covered
This module provides integration between Fast2sms and SMS Framework.
Maintainers of this module are not affiliated with the Fast2sms Group.
There are no external dependencies or special requirements, it's simple installation and configuration has only adding api key from Fast2sms.
Drupal 7
$mobile_number = 'YOUR NUMBER';
$sms_template = 'This is test Message.';
// You need to have fast2sms as default as send it in options
$email_send = sms_send($mobile_number, $sms_template);
Drupal 8 & 9
$sms_service = \Drupal::service('sms.provider');
// Next two lines are optional
$gateway = \Drupal\sms\Entity\SmsGateway::load('fast2sms'); // Name of your gateway you give in config.
$gateway->setSkipQueue(1);
$sms = (new \Drupal\sms\Message\SmsMessage())
->setMessage('This is a test message') // Set the message.
->addRecipient('YOUR NUMBER') // Set recipient phone number
->setGateway($gateway) // This is optional
->setDirection(\Drupal\sms\Direction::OUTGOING);
try {
$sms_service->queue($sms);
}
catch (\Drupal\sms\Exception\RecipientRouteException $e) {
// Thrown if no gateway could be determined for the message.
}
catch (\Exception $e) {
// Other exceptions can be thrown.
}