Sure thing, when using MySQL you use mysqli_real_escape_string()
and check that the type of input received is the kind you expect (string, number, etc) and you can be pretty sure you can use it as input to mysqli_query()
quite securely... right?
Well, the questions are:
- What is the best way to escape a string that's going to be used in
mail()
? - If the email recipient will be the email address entered in a text field, what things should I be careful about to avoid injections or exploits?
I have a pretty good idea how to do this but I'm digging into best practices on this subject to know if I'm missing something, or if there's a better way.
EDIT: The idea of this question is not to have THE answer, but to make a comprehensive collaborative list of all the things to take care of when doing email with PHP.