AlexNogard: IT HowTo

Linux & Opensource : Monitoring : Centreon, Nagios, Owncloud ..


SMS Gateway with Raspberry PI & mail2sms


The SMS Gateway implementation is a simple thing and can be useful in business. Both alerts from your monitoring systems (with Nagios or Centreon for example), only for captive portals Wi-Fi (UCOPIA portal). This gateway is particularly interesting because it is placed on a Raspberry PI, which does not cost much, the GSM modem is an old nokia 3109c.

Configuration :
Raspberry PI 512MO
OS : Pidora
Carte SD : 16GO Class 10

Before start, we update our OS :

# yum update

Modifying our chkconfig :

# chkconfig firewalld off
# chkconfig iptables off
# chkconfig sendmail off


Stopping useless services :

# service firewalld stop
# service iptables stop
# service sendmail stop

We install the prerequisites, namely “smstools” which we will use to send SMS and “postfix”, which will relay our mail2sms:

# yum install smstools postfix

Rights creation :

# chown smstools: /var/spool/sms -R

smssend bin modification :

# vim /bin/smssend

ligne 21 : smsd_user=”smstools”

smsd init.d modification :

# vim /etc/init.d/smsd
sous : prog=”smsd”

// add :

mkdir /var/run/smsd
chown smstools: /var/run/smsd -R

Connect your phone to Raspberry, and edit smstool configuration file :

# vi /etc/smsd.conf

Change the device by /dev/ttyACM0

We install the email2sms tools :

# cp /usr/share/doc/smstools-3.1.15/email2sms /usr/local/bin/email2sms
# chown smstools:smstools /usr/local/bin/email2sms


We modify our postfix configuration file :

# vim /etc/postfix/


Configuration have to be like following :

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
html_directory = no
inet_interfaces = all
inet_protocols = ipv4
local_destination_concurrency_limit = 1
mail_owner = postfix
mailbox_command = procmail -a “$EXTENSION”
mailbox_size_limit = 0
mailbox_transport = smstools
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination =, smsgw, localhost
mydomain =
myhostname =
mynetworks =,
myorigin = $myhostname
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.9.4/README_FILES
recipient_delimiter = +
relay_domains = $mydestination
relayhost = $mydomain
sample_directory = /usr/share/doc/postfix-2.9.4/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
unknown_local_recipient_reject_code = 550


We modify the file :

# vim /etc/postfix/

// add at the end :

smstools        unix    –       n       n       –       –       pipe

       flags= user=smstools argv=/usr/local/bin/email2sms -n ${user}


We add theese services on startup and start them :

# chkconfig smsd on
# chkconfig postfix on
# service smsd start
# service postfix start


To test it :
Connect to a second server, and type the following command:

# /usr/bin/printf “test” | /bin/mailx -S smtp=XXX.XXX.XXX.XXX 33XXXXXXXXXXXX

replace XXX.XXX.XXX.XXX by the sms gateway server IP.

replace XXXXXXXX by your phone number, you should receive the sms.

If you have any questions or comments, the comments are there for that ;)

Feel free to share this article with share buttons !

Leave a Reply

Your email address will not be published. Required fields are marked *