|
-
September 11th, 2010, 02:16 PM
#1
Insert Emailed Information into a Database Automatically
Hi. I'm not so sure if this falls into the category of server-side scripting (since I'm not even remotely sure how to do this), but I'd like to set up an email address, that, when it receives an email, automatically inserts the contents of that email into a database (for example, if the email is:
name: Bob
phone: 5556667777
Then it would enter "Bob" into the "name" column of a new row, and "5556667777" into the "phone" column of that same row.
Does anybody know how I can go about doing this (server-side script or not), or if it's possible at all?
Thanks,
ARDesigns
-
September 11th, 2010, 05:48 PM
#2
Re: Insert Emailed Information into a Database Automatically
Yes, it can be done with most server-side scripting languages. PHP and PERL are two good options. Here's a good PHP tutorial on setting it up through various methods.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
September 11th, 2010, 06:03 PM
#3
Re: Insert Emailed Information into a Database Automatically
Thanks a lot for that link! The tutorial was very helpful and exactly what I was looking for.
Only one last thing:
How can I use PHP to parse the $message variable (which holds the body of the email) so that the text after, but on the same line as, "Name: " that is "name" and then a colon, and then a space, are saved into the variable $name ?
Also, how can I check to make sure that $message contains the word "name:" , and, if it doesn't, to exit the script?
Thanks a lot,
ARDesigns
-
September 11th, 2010, 06:26 PM
#4
Re: Insert Emailed Information into a Database Automatically
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
September 12th, 2010, 02:48 PM
#5
Re: Insert Emailed Information into a Database Automatically
Hi, thanks for all the replies! I've now got the system working:
when I email that email address with:
blah blah blah
Name: Bob
Blah Blah Blah
it inserts "Bob" into the database. My last hurdle here (I know I just said "one more thing," but I promise this is the last thing!) is how to deal with attachments. As I understand it, attachments are stored as a MIME string in the actual MIME data. How can I parse the data out of the raw MIME data that is sent to the PHP file, and then decode the attachment and save it to my server?
Thanks!
-
September 14th, 2010, 03:36 PM
#6
Re: Insert Emailed Information into a Database Automatically
You'll have to parse the attachment data out...once again using those regular expressions. For each attachment there will be boundary header data and then content headers.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|