-1

I have this PHP Mail code:

<?php
$to      = 'chipperyman573@gmail.com';
$subject = 'Application for IGN '.$_POST["IGN"];
$message = 'Skype account: '.$_POST["skype"].'. IGN: '.$_POST["IGN"].'. Timezone: '.$_POST["Timezone"].'. Gender: '.$_POST["Gender"].' Livestreaming/Youtubing: '.$_POST["yt"].'. Accepts rules: '.$_POST["rules"];
$headers = 'From: apply@chipperyman573.com' . "\r\n" .
    'Reply-To: apply@chipperyman573.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

The webpage loads fine, however I don't get the email.

I checked all the $_POST variables and they're all fine.

Jon
  • 2,566
  • 6
  • 32
  • 52
  • 2
    And did you check the return value from `mail(...)`? Or the errors in the page? (You *are* running with `error_reporting` and `display_errors` cranked up, right?) – cHao Jan 13 '14 at 04:32
  • 1
    Also, did you configure your SMTP settings in PHP? Make sure you didn't use SMTP authentication. – Raptor Jan 13 '14 at 04:34
  • Your mail() is fine check your Server Mail Php Mailer Setting – railsbox Jan 13 '14 at 04:38
  • @ShivanRaptor I have. – Jon Jan 13 '14 at 04:39
  • And the message you get at `apply@chipperyman573.com` says...? – cHao Jan 13 '14 at 04:41
  • I never got a message. Also the $to is chipperyman573@gmail.com, did I do something wrong? – Jon Jan 13 '14 at 04:41
  • Then you'd better check where that mail went. If `mail` didn't fail, then either the recipient should get it or you should get back a message saying why they didn't. – cHao Jan 13 '14 at 04:44
  • mail() is notorious for going to spam boxes.. just an fyi. You should really go with smtp. Google PHPMailer. That is what you want to use – Kevin Florida Jan 13 '14 at 05:03
  • I suggest SwiftMailer, a relatively lighter weight PHP mail alternative to PHPMailer, with lots more features. – Raptor Jan 13 '14 at 06:13

1 Answers1

1

The problem does not seem to come from the way you're using the mail function.

It does not seem to come from SMTP server availability either, or else you would have gotten a message similar to this:

Warning: mail() [function.mail]: Failed to connect to mailserver at "xxxx"
port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()
in C:\whatever\my_send_mail.php on line 293

It could, however, come from an authentication problem.

You might want to use dummy SMTP servers like PaperCut to test mailing functions locally before going live on your server.
(that is how I checked your code, by the way)

Of course I could not check the validity of your $_POST values, but I would be surprised if they turned out to be the culprit.
Since you use them only in subject and body, unless they contain really weird things like a bit of SMTP protocol that would confuse the server, they should not be a problem.

If a local send works, the next step will be to check the PHP mailer configuration on your server.

kuroi neko
  • 8,479
  • 1
  • 19
  • 43