We are sending email!
"; } else { echo "

We are NOT sending email!


"; } # change these values to fit your own app $your_app_email = "sharemytaxi@gmail.com"; $your_app_name = "ShareMyTaxi"; /* YOU WOULD HIT THIS SCRIPT FROM... http://itp.nyu.edu/~YOUR_NET_ID_HERE/ubicomp07/logic.php?task=sms&to=MY@EMAIl.COM&from=YOUR@EMAIL.COM&subject=test_subject&body=hello! */ $task = getPOSTorGETValue ("task"); $to = getPOSTorGETValue("to"); $from = getPOSTorGETValue("from"); $subject = getPOSTorGETValue("subject"); $body = getPOSTorGETValue("body"); $filename = getPOSTorGETValue("file"); #clean up the body of the msg $body = strtolower($body); #convert to lowercase first $body = trim($body); #trim whitespace off the beginning + end if ($task == "sms") { #split the incoming message into number & carrier list($number, $host) = split ('[@]', $from); echo "headers from the incoming email:
"; echo "task: " . $task . "
"; echo "to: " . $to . "
"; echo "from: " . $from . "
"; echo "subject: " . $subject . "
"; echo "body: " . $body . "
"; echo "filename: " . $filename . "
"; echo "
"; #log every incoming message $strSQL = "INSERT INTO incoming (xto, xfrom, subject, message, attachment, live) VALUES ('" . $to. "', '" . $from . "', '" . $subject . "', '" . mysql_escape_string($body) . "', '" . $filename . "', '" . $send_email . "')"; echo "Adding incoming msg to database: " . $strSQL . "
"; $rstAdmin = sqlUpdate($strSQL, $mySql); if ($body == "") { $message = "Sorry, but we didn't get anything in your message!"; } else { echo "Okay, we got something!
"; # -- and here is where all the magic happens... ----------- # EXAMPLE 3 # we send in a photo, it sends the photo back to us if ($filename == "") { $message = "Looks like you didn't send us a photo!"; } else { $message = "Hey, looks like this is your photo!"; $file2send = $filename; } shootMail($number, $host, $your_app_name, $your_app_email, $message, $file2send); /* # EXAMPLE 2 # we send a "command" and a "modifier" in the body, and then split the two # e.g. pizza.10002 list($search, $zip) = split ('[.]', $body); if ($search == "") { $message = "You didn't tell us what you were searching for!"; } else if ($zip == "") { $message = "You didn't tell us what zipcode you wanted!"; } else if (is_numeric($zip) == false) { $message = "Wait, the zipcode you gave us is not valid."; } else if (strlen($zip) != 5) { $message = "Wait, the zipcode you give us needs to have 5 numbers!"; } else { $message = "Okay, looks like you are searching for " . $search . " in " . $zip . "!"; } */ /* # EXAMPLE 1 # we send a "command" in the body of the message, and respond to that command if ($body == "") { $message = "Huh? You didn't tell us what animal you wanted to learn about?"; } else if ($body == "dog") { $message = "A dog says woof woof."; } else if ($body == "cat") { $message = "A cat says meow meow."; } else if ($body == "monkey") { $message = "A monkey makes some other kind of noise."; } else { $message = "Sorry, but I don't know what sound a " . $body . " makes."; } */ # --------------------------------------------------------- } shootMail($number, $host, $your_app_name, $your_app_email, $message, $file2send); } else { echo "hi!"; } ?> Send message:
"; echo "number: " . $number . "
"; echo "host: " . $host . "
"; echo "send to: " . $number . "@" . $host . "
"; echo "from: " . $your_app_name . " (" . $your_app_email . ")
"; echo "file to send (if any): " . $file2send . "
"; echo "msg: " . $message . "
"; echo "msg length: " . strlen($message) . "
"; # ------------------------------------------------------------------------- # WE ARE NOW USING DIFFERENT SETTINGS FOR ITP vs. NON-ITP $using_itp = 0; # (1 = itp!, 0 = dreamhost, etc) include('Mail.php'); include('include_libmail.php'); # ------------------------------------------------------------------------- if ($using_itp == 1) { echo "We are using ITP's mail gateway!
"; $headers['From'] = $your_app_name . " <" . $your_app_email . ">"; $headers['Reply-To'] = $your_app_email; $headers['To'] = $number . "@" . $host; $headers['Subject'] = $subject; } else { echo "We are using some non-ITP mail gateway!
"; $headers = ""; $headers = "From: " . $your_app_name . " <" . $your_app_email . ">\r\n"; $headers .= "Reply-To: " . $your_app_email . "\r\n"; } if ($send_email == 1) { if ($using_itp == 1) { ## assign smtp host $params['host'] = 'smtp.gmail.edu'; # Create the mail object using the Mail::factory method $mail_object =& Mail::factory('smtp', $params); if ($file2send == "") { # if sending a text msg back, make sure not to send an MMS if ($host == "vzwpix.com") { $host = "vtext.com"; } else if ($host == "mms.mycingular.com") { $host = "mobile.mycingular.com"; } $to = $number . "@" . $host; $success = $mail_object->send($to, $headers, $message); } else { # this is the code for sending attachments (photos, audio, etc) # if sending an attachment, make sure to send an MMS if ($host == "vtext.com") { $host = "vzwpix.com"; } else if ($host == "mobile.mycingular.com" OR $host == "mycingular.com" OR $host == "cingularme.com") { $host = "mms.mycingular.com"; } $to = $number . "@" . $host; $m= new LMail; // create the mail $m->To( $to ); $m->From( $your_app_email ); $m->ReplyTo( $your_app_email ); #if sprint / blackberry / sidekick / etc. user, then send them an http:// link (can't take photos) if ( $host == "mobile.att.net" OR $host == "attwireless.blackberry.net" OR $host == "mycingular.blackberry.net" OR $host == "messaging.sprintpcs.com" OR $host == "sprintpcs.com" OR $host == "nextel.blackberry.net" OR $host == "tmail.com" OR $host == "tmo.blackberry.net" ) { # change this path to match your setup $message = $message . "http://sharemytaxi.com/ubicomp07/img/" . $file2send . ""; } else { # change this path to match your setup (this one assumes that the "incoming" folder is in the same folder as your "logic.php" file $m->Attach( "img/" . $file2send . "", "image/jpeg"); } $m->Subject( $subject ); $m->Body( $message ); // set the body $m->Send(); // send the mail $success = 1; } } else { if ($file2send == "") { #this is the code that will send a plain old text message # if sending a text msg back, make sure not to send an MMS if ($host == "vzwpix.com") { $host = "vtext.com"; } else if ($host == "mms.mycingular.com") { $host = "mobile.mycingular.com"; } $to = $number . "@" . $host; $to = $number . "@" . $host; $success = mail($to, $subject, $message, $headers, "-f" . $your_app_email . ""); } else { # this is the code for sending attachments (photos, audio, etc) # if sending an attachment, make sure to send an MMS if ($host == "vtext.com") { $host = "vzwpix.com"; } else if ($host == "mobile.mycingular.com" OR $host == "mycingular.com" OR $host == "cingularme.com") { $host = "mms.mycingular.com"; } $to = $number . "@" . $host; $m= new LMail; // create the mail $m->To( $to ); $m->From( $your_app_email ); $m->ReplyTo( $your_app_email ); #if sprint / blackberry / sidekick / etc. user, then send them an http:// link (can't take photos) if ( $host == "mobile.att.net" OR $host == "attwireless.blackberry.net" OR $host == "mycingular.blackberry.net" OR $host == "messaging.sprintpcs.com" OR $host == "sprintpcs.com" OR $host == "nextel.blackberry.net" OR $host == "tmail.com" OR $host == "tmo.blackberry.net" ) { # change this path to match your setup $message = $message . " http://sharemytaxi.com/ubicomp07/img/" . $file2send . ""; } else { # change this path to match your setup (this one assumes that the "incoming" folder is in the same folder as your "logic.php" file $m->Attach( "img/" . $file2send . "", "image/jpeg"); } $m->Subject( $subject ); $m->Body( $message ); // set the body $m->Send(); // send the mail $success = 1; } } if ($success) { echo "
Status: Email sent to: " . $to . "
"; } else { echo "
Status: Email error
"; } #log every outgoing message $strSQL = "INSERT INTO outgoing (xto, xfrom, subject, message, attachment, live) VALUES ('" . $to. "', '" . $your_app_email . "', '" . $subject . "', '" . mysql_escape_string($message) . "', '" . $file2send . "', '" . $send_email . "')"; echo "Adding outgoing msg to database: " . $strSQL . "
"; $rstAdmin = sqlUpdate($strSQL, $mySql); } else { echo "
Status: We're not sending msgs because \"send_email\" = 0
"; } #erase variables just to be safe $number = ""; $host = ""; $to_email = ""; $to_name = ""; $message = ""; } ?>