0

I'm trying to learn a bit of basics of PHP, but as always I start from living examples like mailing. I'm not sure my tutorial was prepared good or I just made a couple of silly mistakes. There may be a problem with " ' because I haven't figured out which one should be where :) So, my mail is not sending an email, and definitely it's not going to spam so I believe I screw up ' and " part. Thanks for help!

$name = $_POST['nick'];
$visitor_email = $_POST['email'];
$visitor_tel = $_POST['tel'];
$message = $_POST['msg'];

$email_from = 'mail@mail.pl';
$email_subject = "Nowe zlecenie: ";
$email_body = "Nowe zlecenie od $name.\n".
"Email kontaktowy: $visitor_email".
"Telefon kontaktowy: $visitor_tel".
"Zlecenie: $message".
$to = 'mail@mail.pl';
$headers = "Od: $email_from \r\n";

mail($to,$email_subject,$email_body,$headers);
Przemysław Lunic
  • 365
  • 1
  • 4
  • 12

1 Answers1

0

For debugging do like below: if(mail($to,$email_subject,$email_body,$headers)) echo "mail sent"; else echo "not send";

Vishnu Sharma
  • 632
  • 5
  • 19
  • I got not send so @Qirel linked and I'm stuck at it: This is important to note because: If you receive a FALSE return value you know the error lies with your server accepting your mail. This probably isn't a coding issue but a server configuration issue. You need to speak to your system administrator to find out why this is happening. So I should already contact administrator or is there any chance to get it working by myself? – Przemysław Lunic Mar 26 '16 at 15:00
  • Yes in this case you should contact administrator. – Vishnu Sharma Mar 26 '16 at 15:04
  • I contacted them! They have told me that mail() is just old and I should use PEAR::Net_SMTP, PEAR::Mail or phpMailer, @vishnu do you know maybe which one would be the best for this and is not that advanced? – Przemysław Lunic Mar 26 '16 at 15:09
  • 1
    You can use phpmailer library to send mails which is easy to use. – Vishnu Sharma Mar 26 '16 at 15:33