ericRed Posted June 3, 2014 Share Posted June 3, 2014 (edited) As the title says, I can send a test e-mail via the Prestashop admin panel, but when I try to send a custom e-mail by code using the PHP mail() function it always returns false. I've tried the simplest code: $to = '[email protected]'; $subject = 'the subject'; $message = 'hello'; $headers = 'From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); if(mail($to, $subject, $message, $headers)){ echo "oh yeah"; } else{ echo "oh no!"; } It returns false. What am I doing wrong? I really appreciate any help you can provide. Edited June 3, 2014 by ericRed (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted June 3, 2014 Share Posted June 3, 2014 you should not use the mail function directly, as it bypasses the email settings you have configured in Prestashop, and instead attempts to use the mail functions defined by your host in the php configuration, which may or may not be valid. Instead you need to use Prestashop Mail::Send function. Link to comment Share on other sites More sharing options...
ericRed Posted June 3, 2014 Author Share Posted June 3, 2014 Thank you for your input; I'll keep it in mind for future projects. As for the problem I had, I think I solved it by setting the From parameter in the mail header as a (fictional) e-mail with the same domain name as the shop itself. Anyhow, it works as intended now so I'll leave it as is. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now