- This topic is empty.
-
AuthorPosts
-
April 11, 2013 at 6:43 pm #44049
KlappenVanJePa
MemberHello,
I have made a php contact page and everthing seems to work, the only problem he sends nothing.
when you enter the page it says that all is well and “message sent”, but when I look at my mail I do not see anything.
Here is the pen http://codepen.io/KlappenVanJePa/pen/amIuJ
Sorry for my bad English, I hope you understand my question.
April 12, 2013 at 2:37 am #131482__
Participantthis:
mail($to, $subject, “From: $email”);
…is the first part of your problem. You’re putting your email headers where the email body should be.
Maybe you meant to do this?
$body = <<
email: $email
naam: $naam
Onderwerp: $onderwerp
vraag: $vragen
EMAIL;# note, mail() comes *after* $body
# in your codepen,
# you try to write the email message
# *after* you send the emailmail( $to,$subject,$body,”From: $email” );
However, your email headers are also malformed – you need to include line breaks after:
“From: $emailrn”
Also, the `From` header should contain an address on the domain that actually *sent* the email (meaning *your* domain), not the email your visitor provided. It is very common for emails to get discarded as spam for this reason, long before getting to your inbox. *(You might even get your web host’s mail server blacklisted, and they will be upset!)*
Also, a good habit is to make sure `mail()` was successful before telling the user their message was, indeed, sent.
Try it like so:
$to = ‘{your email address}’;
$subject = ‘contact’;
$body = <<
email: $email
naam: $naam
Onderwerp: $onderwerp
vraag: $vragen
EMAIL;$headers = “From: no-reply@{your domain}rn”;
$headers .= “Reply-to: $naam <$email>rn”;if( mail( $to,$subject,$body,$headers ) ){
# success!
echo “Bericht verzonden!”;
}
else{
# failed!
echo “Bericht niet verzonden!”;
}April 12, 2013 at 9:20 am #131554KlappenVanJePa
MemberThanks, but when I now upload the file and I fill in the form there comes a new error:
“Parse error: syntax error, unexpected $end in /srv/disk6/1361896/www/portfolio-tw.co.nf/gelukt.php on line 26”
I’ve looked it up and it says that I do not have closed something, but I can’t find the problem.April 12, 2013 at 9:59 am #131560__
ParticipantCan you post your current code so I can check it out?
April 12, 2013 at 10:37 am #131563April 12, 2013 at 2:01 pm #131612__
Participanttwo things:
If you copied/pasted that directly from my post, you’re going to need to do a little fixing. Here on css-tricks, I have to indent the code to make it display in a code block. HOWEVER, a “real” heredoc must have NO characters on the closing line except the closing token.
So, `EMAIL;` (NO spaces or anything else!) will work;
but `…EMAIL;` (pretend those . are spaces) will BREAK EVERYTHING.second,
You’re not showing the part of the code where you got the values from the form (`$name = $_POST`, etc.). I don’t know if you just left them out of your example, but you still need to do that.
April 13, 2013 at 9:53 am #131707KlappenVanJePa
MemberThanks, I have noticed that that is not the only problem was, the other problem was that .co.nf didn’t support php but they say it on there front page.
Thank you very much
April 13, 2013 at 9:57 am #131708__
ParticipantThe code is being parsed (as evidenced by your error messages), so they *do* support PHP.
Do they not support the `mail()` function?
April 28, 2013 at 7:42 am #133410ArmsVsLegs
ParticipantKlappen, I’ve had issues to do with the messages sent by the php mail function just being blocked by the recipient for having malformed headers. Have you set all the parameters?
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.