1) "My email code does not work" is not an error message - you need to be specific regarding your expectations and why your code does not meet these expectations.
2) You do not need all this code to replicate the problem.
You will most likely receive much more help if you are specific and provide relevant information and omit non-essential things.
The code itself is bad. In addition to the absence of any relevant comments and error traps, they are widely open to abuse by inserting an email header. Your regex for checking email addresses will discard valid addresses and accept invalid ones. IIRC, using curly braces around array indices, is deprecated. But this is probably not because it does not meet your expectations.
Assuming mail is not delivered at all, try:
set_error_reporting(E_ALL); init_set("display_errors", 1); trigger_error("If you can't see this then your error reporting is not working"); mail(" your_address@example.com ", "test","hello world");
Most email problems are due to incorrect php configuration or problems with email processing systems.
There is a very good article on diagnosing software problems and getting help to solve them here . Please read it.
source share