问题
If I would like to store emails, but don't have a database (e.g. MySQL), what should I do?
The data should be accessible and writable from PHP, but regular "visitors" MUST NOT see the data.
Hope you can help.
回答1:
If your data not very large, you can use XML files. But if your data is important and you must secure it , you have to encrypt your data
回答2:
You can put them in files :)
$data; // Defined "somewhere"
file_put_contents('filename.txt', $data);
However, I suggest you to use a database anyway. At least SQLite is installed nearly everywere.
回答3:
You can use the php function mail($to, $subject, $body) to send the email address to your personal email. The data will not be readable from your script, but for your use case this might be ok.
回答4:
Look, while I really don't suggest this, in a pinch you can always output it to a .php file with the first line being exit().
So be sure, you can always */ $mail */ to the file, but this is a poor substitute for the security of having a database to store the information.
回答5:
You could do what Outlook does: create your own file format for the mail and dump mails inside. And implement your own reader.(Its re-inventing the wheel sometimes). But its going to award you with a tonne of control over your mails, allowing for easy back up when needed.
来源:https://stackoverflow.com/questions/6095520/store-data-without-a-database