Use SMS content and send Email with PHP

Use SMS content and send Email with PHP SearchSearch
Author Message
lama jallow
New member
Username: Smplx

Post Number: 1
Registered: 06-2015
Posted on Monday, June 22, 2015 - 04:03 am:   

Hello Admin,
I needed a few pointers, will appreciate the help.
I want to use the content of the SMS( in this case the email adress) and send an email to it.
In a sense, NowSMS wil receive the SMS, but in the SMS the person will send their email address as the content, and NowSMS will reply to the message by sending email instead to save the charges of reply msgs.
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 5322
Registered: 08-2008
Posted on Monday, June 22, 2015 - 03:10 pm:   

Hi,

There are multiple ways to do this, depending on whether you have special requirements.

The easy way is to use a mailto: link in the 2-way command. Specify a keyword of *@*, which will match any SMS where the first word in the message is an email address (contains @).

Define the forward to e-mail address similar to this: @@SMSPREFIX@@?subject=SMS+to+e-mail&body=@@SMS@@

@@SMSPREFIX@@ is the first word in the message, which in this case is an email address. @@SMS@@ is the content of the message after the e-mail address. The subject parameter can be whatever you want...just make sure to use + instead of a space character.



Note that in order to actually send the e-mail, e-mail settings need to be defined in NowSMS. For most configurations, you would configure NowSMS to route email via an external IMAP or POP mailbox. For more information on configuring these email settings see http://www.nowsms.com/email-to-sms-mms-gateway-with-nowsms

Alternatively, if you have more advanced custom requirements, you could write a PHP script that processes the message and sends it out as email. See the 10th post at http://support.nowsms.com/discus/messages/1/70113.html, where I provide a simple 2-way command PHP script that accepts the SMS text and forwards it out as e-mail.

--
Des
NowSMS Support
lama jallow
New member
Username: Smplx

Post Number: 2
Registered: 06-2015
Posted on Monday, June 22, 2015 - 04:22 pm:   

Hello Des,
thanks for the response, i appreciate..
i have gone through it all, but i have few misunderstandings. lemme help break it down for you.
1. Users will send an sms message, and the content of the sms is their email address, which means every user will have a different email address.

2. when nowsms receives the sms, all i need is the content of that sms as a variable, which is the email address..

3. i will send a reply by using the mail (using php script) to the email address that was sent as content.

thanks for the usual help.
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 5323
Registered: 08-2008
Posted on Monday, June 22, 2015 - 05:57 pm:   

Hi,

1. So a user sends an SMS like this:

nowsms@nowsms.com This is a test

When NowSMS routes this to a 2-way command:

@@SMSPREFIX@@ = nowsms@nowsms.com (keyword matches *@*)
@@SMS@@ = This is a test

Using 2-way command example above, email will be sent to nowsms@nowsms.com with message text "This is a test".

2. As above

@@SMSPREFIX@@ = nowsms@nowsms.com (keyword matches *@*)
@@SMS@@ = This is a test
@@FULLSMS@@ = nowsms@nowsms.com This is a test

3. If you want to use PHP instead of the built-in email functionality, the 10th post at http://support.nowsms.com/discus/messages/1/70113.html references an example PHP script at http://www.nowsms.com/download/email-php.txt

That script uses a hard coded "To" recipient, but you could change the 2-way command to pass the keyword (e-mail address) as a separate parameter.

For example, instead of:

http://server/email.php?sender=@@SENDER@@&text=@@FULLSMS@@

Use:

http://server/email.php?sender=@@SENDER@@&to=@@SMSPREFIX@@&text=@@SMS@@

And in the script, change:

$to = "****recipient@domain.com****";

to:

$to = $_REQUEST['to'];


--
Des
NowSMS Support
lama jallow
New member
Username: Smplx

Post Number: 3
Registered: 06-2015
Posted on Monday, June 22, 2015 - 06:11 pm:   

Hi,
I need to use PHP for the response. The response i send to the "email address" will be a different key(pass-code) which i will be getting from a database. i dont think nowsms has that functionality in place.

Thanks again..will get in touch.
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 5324
Registered: 08-2008
Posted on Monday, June 22, 2015 - 06:51 pm:   

Right, you would need to use PHP (or another scripting language) to perform that kind of logic. Hopefully that script will help you get started.

--
Des
NowSMS Support