Craigslist has a nice feature where when you respond to a poster you respond to an email such as job-fepsd-1120347193#craigslist.org. The email is then in turn directed to the real email.
I am looking for a couple pointers on how to do this with PHP.
Thanks,
Levi
This is usually done by piping an e-mail address (often, a catch-all address) to PHP. Here's a tutorial on doing it that should get you started in the right direction.
The most probable solution is by doing what they called as Email Piping.
They insert the ad with an identifier like this:
*job-fepsd-1120347193*
alongside with the real email.
Then they receive the email by piping it to a PHP script.
You can check Google for PHP and Piping where you will find good resources on the subject.
The script then searches for this Unique Identifier and associates it with a real email.
Then it forwards the email received to the real person.
There is also another possible solution (but less possible), they might be using POP3.
Then they would just make a check every X minutes on a catch-all address and then forward the message to the right person.
Elastic Email has a simple API for creating two-way anonymous email routing just like craigslist or airbnb. It uses an inbound email api to call a web-hook on your server to resolve the correct email addresses and then relays the email accordingly. It only takes a few lines of code. They have a detailed tutorial here:
https://elasticemail.com/blog/marketing_tips/how-to-build-an-anonymized-email-relaying-feature-using-elastic-email/
Related
I would like to read a data file (such as csv or txt) and mail it using PHP. I would like to be able to have at 5 minute pause in between each send of data. I would also like to use the email field as the senders email. Any help would be appreciated.
Each data chunk will contain:
name
email
address
city
state
zip code
phone
comments
I'm guessing you want to write a newsletter application, so proceeding under that assumption:
You are probably not going to find this answer very helpful, but you should really consider using a newsletter service instead of writing your own code. The reason for this is that sending newsletters requires a LOT more effort and different skills than writing a simple script.
For example, but not exclusively:
Setting up a mailserver correctly.
Taking care about the reverse DNS.
Managing digital signatures (DKIM) for your mail.
Subscribing and tracking sender feedback loops.
Tracking and avoiding DNSBL blocking lists for your server.
etc.
If you really want to write your own code, you have been warned. Take a look at str_getcsv() and SwiftMailer and don't be surprised if you get headaches from this project.
I need to create a system that will pipe incoming emails to a PHP script, then get rid of the email. Technically, I don't want these email addresses to actually exist. I would want to validate the email address by checking a database. So if I have a database with say 100 email addresses (i.e. 2323#mydomain.com), the PHP script would parse the email, store the contents in a database for later use, and then discard the email.
I piped emails to a PHP script in the past and parsed the email. However, my understanding of this requires the email address to exist.
I figure a catch-all account would be a bad idea, as SPAM could account for the majority of incoming emails, which I have no use for.
I could create the emails dynamically perhaps, if that is even possible with PHP, but again, I don't actually need to store the incoming email. Eventually the server would get bogged down with emails that I have no use for, especially since the contents would be stored in a database.
There will be no manual management of the incoming emails. Everything would be automated. While I'm sure I could use the PHP imap extension to delete emails say every 30 days, this seems unnecessary.
Any suggestions on the best setup for this?
Automation of email address creation or wildcard catch
Parsing of email, storing and discarding
Please have a look at a GitHub Project PHPMailer and the documentation is available here.
You can also try sendgrip, another good SMTP mailer for PHP.
These projects do not have a direct functions to delete e-mails, however, you will have to bake your own code extending some of the classes. Good Luck!
See http://harrybailey.com/2009/02/send-or-pipe-an-email-to-a-php-script/ for an excellent article that explains how to pipe incoming mail to a PHP script. You should be able to configure your MTA with a wildcard on your domain (so that it accepts mail to anyaddress#yourdomain.tld) and forward each incoming message to your PHP script. Your PHP script can then pickup the sender, recipient, subject, etc., query your database, and process the message accordingly.
I want to make it so that I can email a url and a php script or something at that url will take the contents I emailed such as message body and write them into a DB. I know how to write something into a DB but I dont know what to do in order to EMAIL to a url or person and have it pull out the message.
The reason I am thinking of emailing to a url if possible is because this saves me the massive blob of trouble of setting up IMAP and using all that mess. I know this can easily be done with php I just have no idea how.
You cannot send email to a URL, you must use a valid email address.
If you want to read your email from within php to import into a DB, you'll need to communicate to your IMAP/SMTP/POP3 server via a socket connection with the fsockopen() function.
I suggest you download any open source web based mail client such as RoundCube, Squirrel Mail, etc... and examine the source code.
There are quite a lot of options when it comes to receiving email. You'll still need to use an email address to send to but you can forward that email on via an HTTP POST using a couple of options such as cURL scripts or using a third party like CloudMailin.
I wrote a blog post about this in Rails (although the principles apply directly to PHP too without much modification. This is a dup of a couple of other questions but it was asked in a fairly different way hence the answer.
I'm making a project in my college, and I am making a web application. This web application is in openSuse. So the OS is Linux and I'm writing the code in php.
Now I want scripts in php for including sms facility in my project. So I need full information how to go about it and what code to implement
You need to use an online SMS provider. A quick trip to google brought up this: http://www.messagemedia.co.uk/sms-gateways.html (UK only, search in your country to find one that'll work for you). Then go to their API page and they should give you a nice PHP API to use.
Two basic approaches
Use an online SMS provider, as suggested by many other comments
Use a GSM modem with software like Gammu to handle sending and receiving text messages; almost any USB GSM dongle can handle this.
If I were to do something like this, I would just use the mail() function of PHP.
In the US at least, I think all phone numbers have an email address:
19999999999#sub.carrier.com
If you can extract the carrier from the number, you could just strip all non-numeric characters from the number and use the PHP mail function to send an email to that address, which in turn is a text message. This is how I forward emails via text to my feature phone (funny, the name is misleading).
There are a number of sites that extract information from the number, but I couldn't find an explicit algorithm. Here's one (I bet you could just use file_get_contents() on that webpage to get the carrier): http://fonefinder.net/
It's not too complicated, so have fun!
Have you seen http://www.twilio.com?
It's really cheap and incredibly easy to use. Why reinvent the wheel? :)
Depends on your needs. If you need to send AND receive and be able to process the incoming messages you are going to need more than just a simple SMS provider and are going to need somebody to partition a short/long code (I'm assuming you don't want to spend 1000$/month on a Short Code) to process incoming messages and forward them to you. You can set up keywords, or regular expressions that get run on messages then forwarded to your server.
If you are just going to be using just outbound SMS (notifications, etc.) than you can use something simple like Clickatell or Twilio.
I have seen on some sites where the user can simply send a blank e-mail to something like verify#domain.com to have their e-mail verified if they are having trouble getting the verification e-mail. I have a website with PHP/MySQL that I'd like to implement this same functionality, but I haven't done much with e-mail besides sending it so I don't even know where to start to set something like this up.
Basically if your mailbox is an IMAP you could reference these functions via PHP http://www.php.net/manual/en/ref.imap.php (if enabled, check your phpinfo()) and read that specific mailbox (http://www.php.net/manual/en/function.imap-open.php).
Run a cronjob every 10 minutes maybe (I say 10minutes as I dont see many people doing this), loop thru all the emails (if any), run your logic to verify that email account, send them an email to say its been verified, then delete that email item from your account so you are not creating a massive backlog of emails.
Its risky way of wanting someone to verify but this is probably one way of doing it.
If your host allows you to, you can pipe received email to a program (in your case, a PHP script), which could then parse the message and decide what to do.
However, I agree that this isn't very secure. It would be very easy to spoof the sender, unless you implement DomainKey checking or DNS lookups.