atmega-ist Posted September 20, 2010 Share Posted September 20, 2010 Greetings, all - Curious to know if someone wouldn't mind taking a look at this code and letting me know if there are any apparent errors that may cause this problem: I attempted sending the message to one of my two 1and1 email accounts and after some delay, it sent it to 1and1 account B but not 1and1 account A. My gmail account, however, gets them every time. I'd like to just say it's some issue with 1and1 but since it successfully got through to the one 1and1 account I'm not comfortable stopping at that. I should also mention that for some reason, as I'm trying it today, the successful 1and1 account will no longer receive the messages... I've tried it with directly copying the php mail code from 1and1's FAQ, though, and it seemed to work for the 1and1 account that was previously succcessful (acct B) but not acct A. Very stuck... Thanks $from = $_REQUEST['email']; $subject = $_REQUEST['subject']; $message = $_REQUEST['question']; mail("username@domain.com", "Subject: $subject", $message, "From: $from"); echo "Mail sent"; 1and1 FAQ with mail code: http://faq.1and1.com/scripting_languages_supported/php_mail_explained/2.html Quote Link to comment Share on other sites More sharing options...
schilly Posted September 20, 2010 Share Posted September 20, 2010 Use $_POST instead of $_REQUEST. Also before you start working with variable just do: mail('email@domain.com','Test Email','Test Body'); to exclude any possible error from the variables you're entering. See if that will send to your 1and1 accounts. If it does then there is a problem with your input vars. Quote Link to comment Share on other sites More sharing options...
rwwd Posted September 20, 2010 Share Posted September 20, 2010 Ga! Please don't use $_REQUEST, there are known security issues with this array (fine to develop with, but please not for a production server!!) I guess as you are using $_POST array? //First protect yourself... $from = strip_tags($_POST['email']); $subject = strip_tags($_POST['subject']); $message = strip_tags($_POST['question']); mail("username@domain.com", "Subject: ".$subject, $message, "From: ".$from); echo "Mail sent"; You can't get much more stripped down than this, but it should function, it has the main ingredients, but please, use a decent tutorial to see the error of what your doing, this is open to all sorts of different methods of abuse; Spam will increase!! Have a try of this one... I guess the one you have chosen is the W3CSchools version, which I quite outdated at the moment, they really should update... Rw Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.