jacob1986 Posted May 4, 2015 Share Posted May 4, 2015 I have written a small contact form using .php in Dreamweaver, the message from the webpage does send... except but I cannot see (in my email client) the recipients email address to send the reply to?Moreover; the webpage has three text boxes ‘Name, Email and Message’, in my email client - I can see the person’s name (in subject line), ‘To’... shows up as my email address - i.e. info@website.com and the message is shown as it should be?The code I have written is as followed:<?php$from="reply.info@website.com";$email="info@website.com";$to ="info@website.com";$subject=$_POST['Subject'];$message=$_POST[ 'Message'];mail ( $email, $subject, $message, "From:".$form);Print "Your Message has been sent";?> Quote Link to comment https://forums.phpfreaks.com/topic/296062-contact-form-using-php-in-dreamweaver/ Share on other sites More sharing options...
ginerjm Posted May 4, 2015 Share Posted May 4, 2015 Spelling is very important in this business. Check it. Quote Link to comment https://forums.phpfreaks.com/topic/296062-contact-form-using-php-in-dreamweaver/#findComment-1510717 Share on other sites More sharing options...
jacob1986 Posted May 4, 2015 Author Share Posted May 4, 2015 I'm kind of stuck... where is my spelling bad? Quote Link to comment https://forums.phpfreaks.com/topic/296062-contact-form-using-php-in-dreamweaver/#findComment-1510726 Share on other sites More sharing options...
Ch0cu3r Posted May 4, 2015 Share Posted May 4, 2015 You have spelled from incorrectly on this line mail ( $email, $subject, $message, "From:".$form); Quote Link to comment https://forums.phpfreaks.com/topic/296062-contact-form-using-php-in-dreamweaver/#findComment-1510727 Share on other sites More sharing options...
jacob1986 Posted May 4, 2015 Author Share Posted May 4, 2015 Thank-you Quote Link to comment https://forums.phpfreaks.com/topic/296062-contact-form-using-php-in-dreamweaver/#findComment-1510728 Share on other sites More sharing options...
ginerjm Posted May 4, 2015 Share Posted May 4, 2015 I do realize that you are new at this, but with only SEVEN lines of code, you really should have been able to find one typo. Quote Link to comment https://forums.phpfreaks.com/topic/296062-contact-form-using-php-in-dreamweaver/#findComment-1510730 Share on other sites More sharing options...
jacob1986 Posted May 4, 2015 Author Share Posted May 4, 2015 I copied it from a youtube video and thought it meant to say form. Quote Link to comment https://forums.phpfreaks.com/topic/296062-contact-form-using-php-in-dreamweaver/#findComment-1510731 Share on other sites More sharing options...
ginerjm Posted May 4, 2015 Share Posted May 4, 2015 Oh - so you didn't write this code (as you said earlier)? Quote Link to comment https://forums.phpfreaks.com/topic/296062-contact-form-using-php-in-dreamweaver/#findComment-1510733 Share on other sites More sharing options...
jacob1986 Posted May 4, 2015 Author Share Posted May 4, 2015 I did write it... as in open php file in dreamweaver - cut html code, then proceeded to write the aforementioned php code from a watching a youtube example of said code. Quote Link to comment https://forums.phpfreaks.com/topic/296062-contact-form-using-php-in-dreamweaver/#findComment-1510737 Share on other sites More sharing options...
jacob1986 Posted May 7, 2015 Author Share Posted May 7, 2015 Can I please ask for help in regards to another small problem, I have the php code below but every time I send a message it doesn't send to my first email address (info@xxxxx.ninja) but instead only sends the message to my Cc profile admin@xxxxx.ninja? Moreover; I also not fixed my initial problem of 'seeing the person email address' in subject line an example of what I mean is below (Example php Code). All I want is to send a message from my webpage to my email client and be able to see the person's name in subject field, plus the person's email address in the reply-to field (of my email client) and lastly have the message send to my first email address and the Cc. Please help! Example php Code: <?php$from="reply.info@xxxx.ninja";$email="info@xxxx.ninja";$to ="info@xxxx.ninja";$subject=$_POST['Subject'];$message=$_POST['Message'];$headers.= "Cc:admin@xxxxx.ninja";mail ($email, $subject, $message, $headers, "From:".$from);Print "Your Message has been sent";?> Example of Email problem: A message that you sent contained a recipient address that was incorrectlyconstructed: From:reply.info@xxxx.ninja missing or malformed local part (expected word or "<")The message has not been delivered to any recipients.------ This is a copy of your message, including all the headers. ------To: info@xxxxx.ninjaSubject: xxxxxx@googlemail.comCc:admin@websiteinfotest.ninjaiooioo Quote Link to comment https://forums.phpfreaks.com/topic/296062-contact-form-using-php-in-dreamweaver/#findComment-1511026 Share on other sites More sharing options...
cyberRobot Posted May 7, 2015 Share Posted May 7, 2015 The "Cc" and "From" information need to be included as the fourth argument (where you have $headers). Example #2 in the documentation for mail() should help show you how. http://php.net/manual/en/function.mail.php Quote Link to comment https://forums.phpfreaks.com/topic/296062-contact-form-using-php-in-dreamweaver/#findComment-1511027 Share on other sites More sharing options...
jacob1986 Posted May 7, 2015 Author Share Posted May 7, 2015 I moved the Cc and from as the fourth argument (the argument is the $from="reply.info@xxxx.ninja" lines under <?php right?) but now I don't receive any emails to my Cc email client plus the information I receive in the email looks like this... xxxxx@googlemail.com <subject line> From reply.info@xxxxx.ninja <reply.info@xxxxxxxx.ninja> To info@websiteinfotest.ninja Cc admin@xxxxx.ninja Reply-to xxxx.ninja@server100.web-hosting.com php code: <?php$email="info@websiteinfotest.ninja";$to ="info@websiteinfotest.ninja";$subject=$_POST['Subject'];$message=$_POST['Message'];$headers = 'From: reply.info@websiteinfotest.ninja'. "\r\n" .$headers = 'Reply-To: websiteinfotest.ninja' . "\r\n" .$headers = 'Cc: admin@websiteinfotest.ninja' . "\r\n" . 'X-Mailer: PHP/' . phpversion();mail ($email, $subject, $message, $headers, $from);Print "Your Message has been sent";?> Quote Link to comment https://forums.phpfreaks.com/topic/296062-contact-form-using-php-in-dreamweaver/#findComment-1511038 Share on other sites More sharing options...
ginerjm Posted May 7, 2015 Share Posted May 7, 2015 You need to use ".=" when trying to concatenate pieces of the header together. Quote Link to comment https://forums.phpfreaks.com/topic/296062-contact-form-using-php-in-dreamweaver/#findComment-1511039 Share on other sites More sharing options...
jacob1986 Posted May 7, 2015 Author Share Posted May 7, 2015 I quickly changed the code to the following (as below) but still the same problem occurs? $headers = 'From: reply.info@websiteinfotest.ninja'. "\r\n" .$headers .= 'Reply-To: websiteinfotest.ninja' . "\r\n" .$headers .= 'Cc: admin@websiteinfotest.ninja' . "\r\n" . Quote Link to comment https://forums.phpfreaks.com/topic/296062-contact-form-using-php-in-dreamweaver/#findComment-1511043 Share on other sites More sharing options...
ginerjm Posted May 7, 2015 Share Posted May 7, 2015 Where is $from defined? Show us your new code too. Quote Link to comment https://forums.phpfreaks.com/topic/296062-contact-form-using-php-in-dreamweaver/#findComment-1511055 Share on other sites More sharing options...
jacob1986 Posted May 7, 2015 Author Share Posted May 7, 2015 <?php$email="info@xxxxxxninja";$to ="info@xxxxxx.ninja";$subject=$_POST['Subject'];$message=$_POST['Message']; $headers = 'From: reply.info@xxxxxx'. "\r\n" .$headers .= 'Reply-To: xxxxxxx' . "\r\n" .$headers .= 'Cc: admin@wxxxxx.ninja' . "\r\n" . X-Mailer: PHP/' . phpversion();mail ($email, $subject, $message, $headers, $from);Print "Your Message has been sent";?> Quote Link to comment https://forums.phpfreaks.com/topic/296062-contact-form-using-php-in-dreamweaver/#findComment-1511056 Share on other sites More sharing options...
cyberRobot Posted May 7, 2015 Share Posted May 7, 2015 As ginerjm indicated, $from doesn't look to be define. With that said, the "From" address is defined in $headers...so the fifth argument can be removed altogether. Side note: you define two variables which I assume contain the "To" address here: $email="info@xxxxxxninja"; $to ="info@xxxxxx.ninja"; However, the mail() function uses the $email variable. So technically you don't need both variables. Quote Link to comment https://forums.phpfreaks.com/topic/296062-contact-form-using-php-in-dreamweaver/#findComment-1511060 Share on other sites More sharing options...
cyberRobot Posted May 7, 2015 Share Posted May 7, 2015 Try changing this $headers = 'From: reply.info@xxxxxx'. "\r\n" . $headers .= 'Reply-To: xxxxxxx' . "\r\n" . $headers .= 'Cc: admin@wxxxxx.ninja' . "\r\n" . X-Mailer: PHP/' . phpversion(); To this $headers = 'From: reply.info@xxxxxx'. "\r\n"; $headers .= 'Reply-To: xxxxxxx' . "\r\n"; $headers .= 'Cc: admin@wxxxxx.ninja' . "\r\n"; $headers .= 'X-Mailer: PHP/' . phpversion(); Note that I replace the concatenation characters at the end with semi-colons. I also added the opening single quote for the "X-Mailer" header. By the way, you don't need to include the "Reply-To" address and the "X-Mailer" header...unless you need them. Quote Link to comment https://forums.phpfreaks.com/topic/296062-contact-form-using-php-in-dreamweaver/#findComment-1511063 Share on other sites More sharing options...
jacob1986 Posted May 7, 2015 Author Share Posted May 7, 2015 Foremost: thank-you for helping me (to all posters). I am going to start again from scratch (building a form and php in Dreamweaver) then I will write the php code again from (as I said) scratch... I will ask for help in the next days to fathom the code operations (argument and so forth). Once again thank-you. Quote Link to comment https://forums.phpfreaks.com/topic/296062-contact-form-using-php-in-dreamweaver/#findComment-1511075 Share on other sites More sharing options...
jacob1986 Posted May 18, 2015 Author Share Posted May 18, 2015 Would it be feasible for someone to tell me if my code is good enough to deter and admonish spammers? Moreover; I have sorted the original problem(s) of the thread. <?phpif($_POST['robots'] != '') { echo 'No spammers here!';} else { // Process the the form} $to = 'general_enquiries@xxxxxx.com'; $subject = 'info help '; $message = 'From: ' . $_POST['name'] . "\n"; $message .= 'Email from: ' . $_POST['email'] . "\n"; $message .= "Message:\n" . $_POST['Message'] . "\n\n"; $headers .= 'Cc: admin@xxxxx.com'; mail($to, $subject, $message, $headers);mail ($email, $subject, $message, "from:".$from);header('Location: xxxxxxxx.com/thank-you.html');exit();?> Quote Link to comment https://forums.phpfreaks.com/topic/296062-contact-form-using-php-in-dreamweaver/#findComment-1512123 Share on other sites More sharing options...
cyberRobot Posted May 19, 2015 Share Posted May 19, 2015 It looks like you're calling the mail() function twice. mail($to, $subject, $message, $headers); mail ($email, $subject, $message, "from:".$from); The second call was probably left in there by mistake. Quote Link to comment https://forums.phpfreaks.com/topic/296062-contact-form-using-php-in-dreamweaver/#findComment-1512218 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.