PHP Mailing Question

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
pdar
Forum Newbie
Posts: 1
Joined: Wed Aug 24, 2005 12:28 pm
Location: USA

PHP Mailing Question

Post by pdar »

I have this script that will mail from where it is currently being hosted. But, if I wanted to have this script mail from an external host, how would I go about doing that? Can anyone offer some advice to this PHP newb.

Here is my code:

Code: Select all

<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>

<?php

$myemail = "myemail@domain.com";
$ccx = "ccemail@domain.com";
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Use the back button - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
}
if(empty($visitor) || empty($visitormail)) {
echo "<h2>Use the back button - fill in all fields</h2>\n";
}
echo $badinput;

$todayis = date("l, F j, Y, g:i a") ;

$attn = $attn;
$subject = $attn;

$notes = stripcslashes($notes);

$message = " $todayis [EST] \n
Attention: $attn \n
Message: $notes \n
From: $visitor ($visitormail)\n
";

$from = "From: $visitor\r\n";

if (($visitormail != ""))
mail($visitormail, $subject, $message, $from);

if ($myemail != "")
mail($myemail, $subject, $message, $from);

if ($ccx != "")
mail($ccx, $subject, $message, $from);

?>


<?php echo $ip ?>
Thanks in advance,
Preston
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'd set up and use phpmailer (http://phpmailer.sf.net). It'll allow your script to act just like a "normal" mail client, sending emails through an smtp server and such
Post Reply