Skip to content

Simple PHP wrapper for the Mailjet API for sending sms

License

Notifications You must be signed in to change notification settings

yohancreemers/mailjet-sms-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

mailjet-sms-php

Simple PHP wrapper for the Mailjet API for sending sms.

Compatibility and depedencies

  • This wrapper requires PHP v5.4 or higher.
  • This wrapper requires cUrl.

Documentation

Official documentation for the API at https://dev.mailjet.com/sms/guides/.

The SMS API the authorization is based on a Bearer token. Signup with Mailjet to get a token https://app.mailjet.com/signup.

Example code

require_once('mailjetsms.php');

//create a new instance
$apikey = '01234567890abcdef01234567890abcdef';
$oApi = new Mailjetsms($apikey);

//Send an SMS
$aData = [
  'from': 'Your sender ID',
  'to': '+31600000000',
  'text': 'Your short message',
];

$oResponse = $oApi->send($aData);

if( $oResponse->success ){
  printf('Message %s is on the way to %s.', $oResponse->MessageId, $oResponse->To);
}else{
  var_dump($oResponse);
}

Optional configuration

It's possible to set a default 'from' and a default 'countrycode'.

$oApi = new Mailjetsms($apikey);
$oApi->from = 'Your sender ID';
$oApi->countrycode = '31';

$aData = [
  'to': '06-12345678',
  'text': 'Your short message',
];

$oResponse = $oApi->send($aData);

About

Simple PHP wrapper for the Mailjet API for sending sms

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages