Jump to content

contact form using .php in Dreamweaver.


jacob1986

Recommended Posts

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";
?>

Link to comment
Share on other sites

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 incorrectly
constructed:

  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.ninja
Subject: xxxxxx@googlemail.com
Cc:admin@websiteinfotest.ninja

iooioo

Link to comment
Share on other sites

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";


?>

Link to comment
Share on other sites

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" .

Link to comment
Share on other sites

<?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";


?>

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 weeks later...

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. 

 

<?php

if($_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();

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.