Cameron
Cameron

Reputation: 1021

How can I process incoming email messages with PHP?

I want to process incoming emails to an address and insert them into a mysql database. I am using a grid-service media temple host with SHH access but I have no idea where to start. I also want to store attachments or copy them to a directory on my host and save the url in the database.

Upvotes: 0

Views: 2325

Answers (3)

Chris
Chris

Reputation: 4810

Why not pipe the emails instead of using imap_open()? This would allow you to access the email immediately as it comes in, and then decide if you even want it stored in the inbox.

Upvotes: 0

SimonMayer
SimonMayer

Reputation: 4916

The simplest way to process incoming mail in PHP is imap_open(), which you can use to open a mailbox, either using IMAP4 or POP3. You would need to run your script periodically, or at least regularly run imap_ping() to 'poll' for new messages.

Upvotes: 0

eoinoc
eoinoc

Reputation: 3265

Since you say you don't know where to start, my one suggestion would be to look at the inbound email service offered at Postmark. I believe there are several such services.

Upvotes: 0

Related Questions