Help with webform auto reply

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

Post Reply
phpnewbie10
Forum Newbie
Posts: 1
Joined: Fri Nov 05, 2010 6:53 am

Help with webform auto reply

Post by phpnewbie10 »

I am new to php . I've added an auto reply email script to my webform to go out when the summit button is clicked, which works.
The problem I have is that when the email arrives at the destination inbox, it appears to come from anonymous@domainname.com, instead of info@domainname.com. The emails are treated as spam mail and goes directly to the junk box. My web host provider now thinks I am are sending spam mail from our site and temporarily disconnect the page.
Could somone please help me fix this. The script is below


if($_POST['btnSubmit']=="Send")

{
echo "Thank You. Your registration was successfully sent.";
}

$to = "$email";
$from = "info@domainname.com";
$subject = "Registration confirmation";
$body = <<< emailbody


This email confirms your registration. We will contact you as soon as possible


emailbody;
$success = mail($to,$from,$subject,$body,
"From:$from\r\nReply-To:"info@domainname.com";
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Help with webform auto reply

Post by Jonah Bron »

Invalid argument. You're using the second argument to mail as the from field. The manual shows the correct usage:

http://php.net/manual/en/function.mail.php
Post Reply