Hey there,
I have seen some web apps that allow me to email stuff to a special ID and it magically turns up in my account. How exactly do they do this?
Hey there,
I have seen some web apps that allow me to email stuff to a special ID and it magically turns up in my account. How exactly do they do this?
Without you giving an example of the specific service you're thinking of, it's hard to know exactly, but one way could be:
you give your email address to one of these sites, e.e. magic-mail.com
they insert this into their db, and take the db id
value for this entry (12345
)
they give you an address using this id ([email protected]
)
when mail is received by magic-mail.com
, they look up the part before the @
, pull out the associated email address for that ID, and relay the message on to the address you gave initially ([email protected]
)
There are many other ways of doing this, likely more simple than the above, but again, without examples it's hard to tell you exactly how the site you're thinking of is operating.
On reading the question, I assumed "my account" meant your mail account. If you meant an account you have on this company's system, then the process would be the same as the above, but changing the last step to:
magic-mail.com
, they look up the part before the @
, pull out the associated email address for that ID, and copy the contents of the message to the account associated with that id.Yes, sorry for the generic nature of the question.. I did not quite know how to phrase it. So let me try again by giving a specific case of what I wish to do.
I have a website hosted on a standard hosting plan. So I have an email addy [email protected]. Now, I want to do this: When I send an email to this ID, I want a script to read its contents, and then copy the content to the DB.
Would I be able to do this using standard PHP, or do I need any special tools available from my web hosting side to be able to perform this task?
Thanks.
You can write a simple script on python/php or any language your know. Make it recieve a pop mail for account '[email protected]' and put the content to db.
It is quite easy.
You would need a way to monitor the mail account for new messages, read the message format, parse out the parts that are important to you and then perform the insert.
Monitoring the mail account would require having a script running on the server in a specified interval, otherwise the only other way would be to access a certain URL manually which would access the mail account and do all the necessary processing.
Depending on your hosting provider and the amount of freedom they give you, this may or may not be possible.
Short way:
You need to write a script that will connect to mail server, fetch mails, parse them and then put to database.
Run this in a cron job and you're set.