| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| NamePros Member | php form wont fwd email I want my email address 1@mydomain.com to forward to two other email address: 2@google.com, 3@comcast.net It works perfect via email. But I have a php-form developed to send an email to #1...but #3 is never forwarded the message. Am I forgetting something? |
| |
| | #3 (permalink) | |
| NamePros Member | Quote:
I actually got the code from a NP post!... <?php //Start your PHP tags foreach($_POST as $key => $val){ $$key = trim($val); } function em($ema){ if(!eregi('[a-z0-9]+[_a-z0-9-]*(\.[_a-z0-9-]+)*@[a-z?G0-9]+(-[a-z?G0-9]+)*(\.[a-z?G0-9-]+)*(\.[a-z]{2,4})$', $ema, $ema_er)){ return 0; } else { return 1; } } if(em($email) != 0){ $error = "<span class='error'>Error<br />The email you entered is an invalid email address, Please input the correct email!</span>"; include("feedback.php"); exit(); } if((!$name) || (!$email) || (!$comments)) { $error = "<span class='error'><br /></span>"; include("feedback.php"); exit(); } else { $ip = $_SERVER['REMOTE_ADDR']; $ref = $_SERVER['HTTP_REFERER']; $to = "1@mydomain.com"; $date = date("m/d/Y"); $time = date("h:i:s A"); $subject = "My .com form has a message for you"; $msg = "Feedback from $username. Here are their comments: $comments \n\n Came from: $ref At: $ip| $date | $time"; $mailheaders = "From: 1@mydomain.com<1@mydomain.com> \n\r"; $mailheaders .= "X-Mailer: DP-Mail X-2 \n\r\n\r"; mail($to, $subject, $msg, $mailheaders); $error = "<span class='true'>We have successfully sent your contact form! </span>"; include("feedback.php"); exit(); } // Close PHP tags. | |
| |
| | #4 (permalink) |
| NamePros Legend | try this one, you may or may not need to change the subject: Code: <?php
if ($comments)
{
$emess = "This is what the person said\n\n";
$emess.= "-------------------------------------------------\n\n\n";
$emess.= "Comments:\n $comments\n\n";
$emess.= "Contact Info:\n $name\n";
$ehead= "$email\r\n";
$subj = "Contact Form";
$mailsend=mail("1@mydomain.com","$subj","$emess","$ehead");
echo "Thanks for the email.<br>";
echo "I'll get back to you as soon as I can using the email you provided.";
}
else
{
echo "<b>Contact Me</b><br><br>";
echo '<form method="post" action="'.$PHP_SELF.'"> ';
echo 'Name: <br>';
echo '<input type="text" name="name"><br><br>';
echo 'Contact Email: <br>';
echo '<input type="text" name="email"><br><br>';
echo 'Message: <br>';
echo '<textarea name="comments" rows="5" cols="30"></textarea><br><br>';
echo '<br>';
echo '<input type="submit" value="Contact Me!"><br>';
echo '</form>';
}
?>
|
| |
| | #5 (permalink) |
| Buy my domains. | The reason it only goes to 1@yourdomain.com is because the line that says where it goes to. ![]() $to = "1@mydomain.com"; It can't magically know where else you want it to go. Change the above line to: $to = "1@mydomain.com, 2@mydomain.com, 3@mydomain.com"; |
| |
| | #6 (permalink) |
| NamePros Member | Dan- Thanks, I understand that part. But what I'm trying to do is set up 1@mydomain.com to forward the email to the other 2 addresses. This allows the public/bots to only see @mydomain instead of @comcast.com and @hotmail.com. Weblord. Thank you, trying it now. |
| |
| | #9 (permalink) | |
| NamePros Legend | the forwarding part do that via email setiings not via script the script i gave above try it saving it as .php and then view source, it won't show up your email address to be harvested by spammers, meanwhile do the redirect to 2 other email addresses via your email settings on cpanel. hth Quote:
| |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |