Sending free SMS over the SWITCH Mailgateway

One of the nice aspects of working in a universitary environment is, that you can take advance of many nice little things. For example, you can send free SMS via the Switch Mailgateway (

To do so, I wrote a simple PHP script, wich enables me to send SMS via a little Textbox through a Website. I used the PEAR Framework to implement the mailing- function. For readability I stripped away the HTML forms and JavaScript functions, wich limited the form’s capacity to the SMS- usual 160 characters.


if (isset($_POST['smsor_message'])) {
	$options = array (
		'host'      => '',
		'auth'      => false,
	$mailer = Mail::factory('smtp', $options);
	if (true === PEAR::isError($mailer)) {
		die ($mailer->getMessage());
	$headers = array(
		'From' => '',
		'To' => $_POST['smsor_to']."",
	$res = $mailer->send($_POST['smsor_to']."",

	if (true === PEAR::isError($res)) {
		die ($res->getMessage());
	echo "Message <br>\n<i>".$_POST['smsor_message']."</i><br>\n
		sent to <i>".$_POST['smsor_to']."</i><br>\n";
	echo "<br><hr><br>";