For my implementation I needed the mail parsed by PlaySMS to be in a different format than it exists currently.
Current implementation is that the Subject holds the @user, PIN and then the message and the Body contains the number(s) to dial.
I needed the opposite so I edited fn.php from:
foreach ($emails as $email_number ) {
$overview = imap_fetch_overview($inbox, $email_number, 0);
$email_subject = trim($overview[0]->subject);
$email_sender = trim($overview[0]->from);
$email_body = trim(imap_fetchbody($inbox, $email_number, 1));
_log('email from:[' . $email_sender . '] subject:[' . $email_subject . '] body:[' . $email_body . ']', 3, 'mailsms_hook_playsmsd');
$e = preg_replace('/\s+/', ' ', trim($email_subject));
$f = preg_split('/ +/', $e);
$sender_username = str_replace('@', '', $f[0]); // in case user use @username
$sender_pin = $f[1];
//$message = str_replace($sender_username . ' ' . $sender_pin . ' ', '', $email_subject);
$c_message = preg_split("/[\s]+/", $email_subject, 3);
$message = $c_message[2];
$sender = user_getdatabyusername($sender_username);
if ($sender['uid']) {
$items = registry_search($sender['uid'], 'features', 'mailsms_user');
$pin = $items['features']['mailsms_user']['pin'];
if ($sender_pin && $pin && ($sender_pin == $pin)) {
if ($items_global['features']['mailsms']['check_sender']) {
preg_match('#\<(.*?)\>#', $email_sender, $match);
$sender_email = $match[1];
if ($sender['email'] != $sender_email) {
_log('check_sender:1 unknown sender from:' . $sender_email . ' uid:' . $sender['uid'] . ' e:' . $sender['email'], 3, 'mailsms_hook_playsmsd_once');
continue;
}
}
} else {
_log('invalid pin uid:' . $sender['uid'] . ' sender_pin:[' . $sender_pin . ']', 3, 'mailsms_hook_playsmsd_once');
continue;
}
} else {
_log('invalid username sender_username:[' . $sender_username . ']', 3, 'mailsms_hook_playsmsd_once');
continue;
}
// destination numbers is in array and retrieved from email body
// remove email footer/signiture
$sms_to = preg_replace('/--[\r\n]+.*/s', '', $email_body);
$sms_to = explode(',', $sms_to);
to
foreach ($emails as $email_number ) {
$overview = imap_fetch_overview($inbox, $email_number, 0);
$email_subject = trim($overview[0]->subject);
$email_sender = trim($overview[0]->from);
$email_body = trim(imap_fetchbody($inbox, $email_number, 1));
_log('email from:[' . $email_sender . '] subject:[' . $email_subject . '] body:[' . $email_body . ']', 3, 'mailsms_hook_playsmsd');
$e = preg_replace('/\s+/', ' ', trim($email_body));
$f = preg_split('/ +/', $e);
$sender_username = str_replace('@', '', $f[0]); // in case user use @username
$sender_pin = $f[1];
//$message = str_replace($sender_username . ' ' . $sender_pin . ' ', '', $email_subject);
$c_message = preg_split("/[\s]+/", $email_body, 3);
$message = $c_message[2];
$sender = user_getdatabyusername($sender_username);
if ($sender['uid']) {
$items = registry_search($sender['uid'], 'features', 'mailsms_user');
$pin = $items['features']['mailsms_user']['pin'];
if ($sender_pin && $pin && ($sender_pin == $pin)) {
if ($items_global['features']['mailsms']['check_sender']) {
preg_match('#\<(.*?)\>#', $email_sender, $match);
$sender_email = $match[1];
if ($sender['email'] != $sender_email) {
_log('check_sender:1 unknown sender from:' . $sender_email . ' uid:' . $sender['uid'] . ' e:' . $sender['email'], 3, 'mailsms_hook_playsmsd_once');
continue;
}
}
} else {
_log('invalid pin uid:' . $sender['uid'] . ' sender_pin:[' . $sender_pin . ']', 3, 'mailsms_hook_playsmsd_once');
continue;
}
} else {
_log('invalid username sender_username:[' . $sender_username . ']', 3, 'mailsms_hook_playsmsd_once');
continue;
}
// destination numbers is in array and retrieved from email body
// remove email footer/signiture
$sms_to = preg_replace('/--[\r\n]+.*/s', '', $email_subject);
$sms_to = explode(',', $sms_to);