开发者

How to get emails and save them into mysql database [duplicate]

开发者 https://www.devze.com 2023-03-16 08:34 出处:网络
This question already has answers here: How do I receive email and process it in a web application 开发者_Python百科
This question already has answers here: How do I receive email and process it in a web application 开发者_Python百科 (11 answers) Closed 8 years ago.

I got requirement to build a email box. In which I am going to save incomming and outgoing emails in/out of mysql database. How can I write a php script so my all emails will arrive in my mysql database?


PHP is a web scripting language primarily designed for building web applications. Your requirement seems to be more of a system application.

It's hard to determine what you will need to do because all mail servers offer different apis and storage options. I would suggest, if possible, you tell your mail server to store the messages on the file system and then use something along the lines of Python, C#, or C++ to watch the directory and then parse out the emails once they are added.

Note: You can still use PHP in this manner through calling the script with php.exe, but I really wouldn't recommend it. There are many better languages out there for doing what you are trying to do.

You can then schedule your application to check file modification times and then if a file has been added since your last process run you can parse the email and use a database driver (through your programming language) and insert into the database accordingly.

There also may exist some email servers that actually store the messages directly into a database. Then you can build queries that can move and archive the data into a table/schema of your choice.

Hope this helps,

Jeffrey Kevin Pry

0

精彩评论

暂无评论...
验证码 换一张
取 消