2010-07-26 4 views
0

내가 야후 Gmail과 같은받는 사람에게 이메일을 보내는 작업입니다 내 코드localhost에서 gmail이나 yahoo 또는 rediff로 메일을 보내시겠습니까?

<!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

실제 이메일 작성/전송을 수행하려면 PHPMailer과 같은 것을 사용하십시오. 그 외에도 SMTP 서버를 로컬로 실행하거나 이메일의 물리적 전송을 처리 할 수있는 다른 곳 (ISP의?, Google?)에 액세스해야합니다.

+0

또한 이러한 메시지를 직접 보내려는 경우 RFC 822에 익숙해야합니다. 헤더는 메시지 본문과 함께 올바르게 형식화되어야합니다. Gmail, yahoo 등은 메시지 형식을 올바르게 지정하지 않으면 이메일을 스팸 함으로 전송합니다. 메일의 형식을 올바르게 지정하는 방법에 대해 걱정하지 않으시면 PHPMailed를 사용하는 것이 좋습니다. – Chris

0

실행하려면 php.ini의 mail()에 setup an smtp server을 사용해야합니다.

localy (프로덕션 서버가 아닌)의 스크립트를 테스트하는 경우 ISP의 SMTP를 사용하여 트릭을 수행 할 수 있습니다.

+0

완전히 사실이 아닙니다. Google과 같은 모든 SMTP 서버를 사용할 수 있습니다 (예 : http://lifehacker.com/111166/how-to-use-gmail-as-your-smtp-server –

+0

사실, ISP의 SMTP를 사용하도록 제안했습니다. :) – Youssef

관련 문제