2010-07-22 151 views
1

我的工作,如雅虎的Gmail电子邮件发送到任何收件人 我的代码是 接触形式如何发送电子邮件?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Email Form </title> 
</head> 
<body> 

<form method="post" action="sendeail.php"> 

<!-- DO NOT change ANY of the php sections --> 
<?php 
$ipi = getenv("REMOTE_ADDR"); 
$httprefi = getenv ("HTTP_REFERER"); 
$httpagenti = getenv ("HTTP_USER_AGENT"); 
?> 

<input type="hidden" name="ip" value="<?php echo $ipi ?>" /> 
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" /> 
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" /> 


Your Name: <br /> 
<input type="text" name="visitor" size="35" /> 
<br /> 
Your Email:<br /> 
<input type="text" name="visitormail" size="35" /> 
<br /> <br /> 
<br /> 
Attention:<br /> 
<select name="attn" size="1"> 
<option value=" Sales n Billing ">Sales n Billing </option> 
<option value=" General Support ">General Support </option> 
<option value=" Technical Support ">Technical Support </option> 
<option value=" Webmaster ">Webmaster </option> 
</select> 
<br /><br /> 
Mail Message: 
<br /> 
<textarea name="notes" rows="4" cols="40"></textarea> 
<br /> 
<input type="submit" value="Send Mail" /> 
<br /> 
</form> 

</body> 
</html> 

和senemail.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Sendemail Script</title> 
</head> 
<body> 

<!-- Reminder: Add the link for the 'next page' (at the bottom) --> 
<!-- Reminder: Change 'YourEmail' to Your real email --> 

<?php 

$ip = $_POST['ip']; 
$httpref = $_POST['httpref']; 
$httpagent = $_POST['httpagent']; 
$visitor = $_POST['visitor']; 
$visitormail = $_POST['visitormail']; 
$notes = $_POST['notes']; 
$attn = $_POST['attn']; 


if (eregi('http:', $notes)) { 
die ("Do NOT try that! ! "); 
} 
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) 
{ 
echo "<h2>Use Back - Enter valid e-mail</h2>\n"; 
$badinput = "<h2>Feedback was NOT submitted</h2>\n"; 
echo $badinput; 
die ("Go back! ! "); 
} 

if(empty($visitor) || empty($visitormail) || empty($notes)) { 
echo "<h2>Use Back - fill in all fields</h2>\n"; 
die ("Use back! ! "); 
} 

$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 
Additional Info : IP = $ip \n 
Browser Info: $httpagent \n 
Referral : $httpref \n 
"; 

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


mail("YourEmail", $subject, $message, $from); 

?> 

<p align="center"> 
Date: <?php echo $todayis ?> 
<br /> 
Thank You : <?php echo $visitor ?> (<?php echo $visitormail ?>) 
<br /> 

Attention: <?php echo $attn ?> 
<br /> 
Message:<br /> 
<?php $notesout = str_replace("\r", "<br/>", $notes); 
echo $notesout; ?> 
<br /> 
<?php echo $ip ?> 

<br /><br /> 
<a href="contact.php"> Next Page </a> 
</p> 

</body> 
</html> 

我必须在我的本地制作,这样的变化是什么我将能够发送邮件...

谢谢。

回答

0
+0

发送电子邮件的概念,但他并没有要求一个红宝石的解决方案! – 2ndkauboy 2010-07-22 06:09:53

+0

我只是想通过我的本地主机,我将能够发送电子邮件... – rajesh 2010-07-22 06:10:53

+0

我以为他问他如何改变他的机器发送电子邮件。无论语言如何,该链接都会谈到所需的所有步骤。 – andychase 2010-07-22 06:12:21

0

我会强烈建议使用PHPMailer

编辑:为了能够发送邮件到本地主机,您需要在本地计算机上运行邮件服务器,或者连接到您拥有帐户的STMP服务器。第二个不能用PHP的mail()函数完成,但用PHPMailer(see this example)完成。

+0

我同意这一点,如果你看我的链接这是一个非常艰难的壮举。 – andychase 2010-07-22 06:12:54

+0

如何使用该服务 请建议。 – rajesh 2010-07-22 06:14:20

+0

如果您的本地主机上运行了XAMPP,则会包含邮件服务器。如果您不想运行自己的邮件服务器,只需通过您拥有帐户的邮件服务发送即可。如果你有一个托管服务,你甚至可以发送任何电子邮件地址的邮件。如何设置XAMPP邮件服务器,可以在这里找到:http://www.youtube.com/watch?v = _QnfF64rA78 – 2ndkauboy 2010-07-22 06:20:28