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. [email protected] and the message is shown as it should be?

The code I have written is as followed:

<?php
$from="[email protected]";
$email="[email protected]";
$to ="[email protected]";
$subject=$_POST['Subject'];
$message=$_POST[ 'Message'];
mail ( $email, $subject, $message, "From:".$form);
Print "Your Message has been sent";
?>

Link to comment
https://forums.phpfreaks.com/topic/296062-contact-form-using-php-in-dreamweaver/
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 ([email protected]) but instead only sends the message to my Cc profile [email protected]? 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="[email protected]";
$email="[email protected]";
$to ="[email protected]";
$subject=$_POST['Subject'];
$message=$_POST['Message'];
$headers.= "Cc:[email protected]";

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:[email protected]  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: [email protected]
Subject: [email protected]
Cc:[email protected]

iooioo

I moved the Cc and from as the fourth argument (the argument is the $from="[email protected]" 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...

 

[email protected] <subject line>

 

From         [email protected] <[email protected]>

To             [email protected]

Cc             [email protected]

Reply-to    [email protected]

 

 

php code:

 

<?php

$email="[email protected]";
$to ="[email protected]";
$subject=$_POST['Subject'];
$message=$_POST['Message'];
$headers = 'From: [email protected]'. "\r\n" .
$headers = 'Reply-To: websiteinfotest.ninja' . "\r\n" .
$headers = 'Cc: [email protected]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail ($email, $subject, $message, $headers, $from);


Print "Your Message has been sent";


?>

<?php

$email="info@xxxxxxninja";
$to ="[email protected]";
$subject=$_POST['Subject'];
$message=$_POST['Message'];

 

$headers = 'From: reply.info@xxxxxx'. "\r\n" .
$headers .= 'Reply-To: xxxxxxx' . "\r\n" .
$headers .= 'Cc: [email protected]' . "\r\n" .

 

X-Mailer: PHP/' . phpversion();

mail ($email, $subject, $message, $headers, $from);


Print "Your Message has been sent";


?>

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 ="[email protected]";
 
However, the mail() function uses the $email variable. So technically you don't need both variables.

Try changing this

$headers = 'From: reply.info@xxxxxx'. "\r\n" .
$headers .= 'Reply-To: xxxxxxx' . "\r\n" .
$headers .= 'Cc: [email protected]' . "\r\n" .
 
X-Mailer: PHP/' . phpversion();
 
To this
$headers  = 'From: reply.info@xxxxxx'. "\r\n";
$headers .= 'Reply-To: xxxxxxx' . "\r\n";
$headers .= 'Cc: [email protected]' . "\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.

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.

  • 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 = '[email protected]';
            $subject = 'info help  ';
            $message  = 'From: ' . $_POST['name'] . "\n";
            $message .= 'Email from: ' . $_POST['email'] . "\n";
            $message .= "Message:\n" . $_POST['Message'] . "\n\n";
            $headers .= 'Cc: [email protected]';
            mail($to, $subject, $message, $headers);


mail ($email, $subject, $message, "from:".$from);

header('Location: xxxxxxxx.com/thank-you.html');
exit();

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.