Note: This is not a duplicate of this question, as mine DOES send mail, but it doesn't arrive on the email hosted on the same server as the website.
I have set up a little form on my Wordpress-page through which people can sign up for a course. This form sends a confirmation to the person that signed up, but should also send an email to me telling me someone signed up for a course.
Let's say they sign up on yyy.com. The email telling me someone signed up for a course, should send an email to xx@yyy.com. However, it never arrives, neither does it get thrown in my spam box.
When I change the email to xx@gmail.com, it works without a problem. I have read about this, and it might have something to do with the server trying to email itself (the mail is hosted on the same server) and by that trying to do it locally (and failing horribly at that).
Here's my code:
$email_to = "xx@gmail.com,xx@yyy.com";
$subject_billetten = "En deltager har tilmeldt sig kurset " . get_the_title();
$place = get_post_meta(get_the_ID(), 'place', true);
$date_start = get_post_meta(get_the_ID(), 'date_start', true);
$fornavn_kursist = $_POST['firstname'];
$efternavn = $_POST['lastname'];
$message_billetten =
'En deltager har tilmeldt sig kurset ' . get_the_title() . ' den ' . strftime("%a, %e. %b. %Y", $date_start) . ' i ' . $place . "\r\n" .
'Navn: ' . $fornavn_kursist . ' ' . $efternavn . "\r\n" .
'Email: ' . $email;
wp_mail($email_to, $subject_billetten, $message_billetten, $headers = 'From: Kursus <info@yyy.com>');
Now, is there a way to fix this, without having access to the server which handles the wp_mail();
-function? I tried changing it to just mail();
, but that doesn't solve it.
P.S. I have the same problem if I make a new user in that Wordpress-installation and check the "send this new user his login and password"-function. That confirmation email will never arrive. I tell you this, because it makes me think that the fault can't be found in my code.