Contact form issue???

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Just as an aside, any time your variables print out as the variable and not the value of the variable, it is almost 100% string type and quote issues. You might want to read up on PHP Strings.

Code: Select all

<?php
$hello = 'HELLO';

// Prints $hello world
echo '$hello world';

// Prints HELLO world
echo "$hello world";

// As does this
echo $hello . ' world';
?>
mikewooten
Forum Contributor
Posts: 169
Joined: Wed Feb 11, 2004 12:13 pm
Location: Duluth, Georgia
Contact:

Post by mikewooten »

ok that works, but the only thing now is that the auto respond does not work, this is what i have added, what do i need to add or change to get this to work?

Code: Select all


 $user_email2 = $_POST["user_email2"]; 
$message = $_POST["message"]; 
$auth_name2 = "Mike Wooten"; 
  
$to      = 'mikewooten@wootenmedia.com'; 
$subject = 'subject here'; 
$headers = "From: $user_email2" . "\r\n" . 
   'Reply-To: mikewooten@wootenmedia.com' . "\r\n" . 
   'X-Mailer: PHP/' . phpversion(); 

echo "<pre>mail($to, $subject, $message, $headers);</pre>"; 
mail($to, $subject, $message, $headers); 

$headers2 = "MIME-Version: 1.0\r\n Content-Type: text/plain Charset=iso-8859-1\r\n From: $to";

$autorespond = mail("$user_email2", "Thanks For Your Email Inquiry", "Your email was sent successfully to $auth_name2. We will respond as soon as possible.",$headers2); 

echo '<font face="Arial">Your Email has been sent!</font>';

User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Mail returns a boolean. Try not setting $autoresponse equal, but instead just call it directly. I am not sure that will help, but it is worth a shot.
mikewooten
Forum Contributor
Posts: 169
Joined: Wed Feb 11, 2004 12:13 pm
Location: Duluth, Georgia
Contact:

Post by mikewooten »

how would i call it directly?
like this??

Code: Select all


$autorespond("$user_email2", "Thanks For Your Email Inquiry", "Your email was sent successfully to $auth_name2. We will respond as soon as possible.",$headers2); 

User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Code: Select all

<?php
$user_email2 = $_POST["user_email2"];
$message = $_POST["message"];
$auth_name2 = "Mike Wooten";
 
$to = 'mikewooten@wootenmedia.com';
$subject = 'subject here';
$headers = "From: $user_email2" . "\r\n" .
   'Reply-To: mikewooten@wootenmedia.com' . "\r\n" .
   'X-Mailer: PHP/' . phpversion();

// Mail the actual message
mail($to, $subject, $message, $headers);

// Handle autoresponse
$headers2 = "MIME-Version: 1.0\r\n Content-Type: text/plain Charset=iso-8859-1\r\n From: $to";
if ( mail($user_email2, "Thanks For Your Email Inquiry", "Your email was sent successfully to $auth_name2. We will respond as soon as possible.", $headers2) )
{
    echo '<font face="Arial">Your Email has been sent!</font>';
}
else
{
    echo '<font face="Arial">SORRY IT DID NOT WORK</font>';
}
?>
This is just a brief generic way of doing it.
mikewooten
Forum Contributor
Posts: 169
Joined: Wed Feb 11, 2004 12:13 pm
Location: Duluth, Georgia
Contact:

Post by mikewooten »

ok this works when i use my server addresses from wootenmedia, but when i type in an address from yahoo, i don't get an autoresponse from yahoo, aol etc.. is there anything that i can do to bypass that?

also, when i get the autoresponse, the "From" field shows up as nobody instead of the users email address. how can i get the "from" field to show the users email address?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Yahoo, aol, hotmail, etc might have spam filters that prevent messages like this. As for changing the name, look at the header details and see if it can be worked on there. Otherwise, it may be a server thing that only your host can fix.
mikewooten
Forum Contributor
Posts: 169
Joined: Wed Feb 11, 2004 12:13 pm
Location: Duluth, Georgia
Contact:

Post by mikewooten »

it might not be able to be worked on, i don't know, unless something can be changed in the script for this to work, but i have asked the hosting server if "Nobody" could be disabled, and they came back saying:
As for some security reasons we do not disable the option server wide. Disabling the option will increase the spam mails. So we don't disable the option.
if it is something with the header details, what could be changed in the header?

also, is there any other way to get around yahoo, aol spam filers?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

This is about the best thing I've seen for sending emails that actually get to where they need to get to.
Everah wrote:It might not make a difference, but have you looked into using a package, like Swiftmailer?
Post Reply