2013-03-05 2 views
-1

PHP 메일() 기능을 사용하는 HTML 양식이 있습니다. 내가 사용하고있는 SMTP 서버는 localhost이며 인증을 필요로하지 않습니다.PHP는 HTML 메일을 보내지 않습니다.

<?php 

$name = $_POST['name']; 
$email = $_POST['email']; 
$phone = $_POST['phone']; 
$call = $_POST['call']; 
$website = $_POST['website']; 
$message = $_POST['message']; 
$formcontent = 'From: $name \n Phone: $phone \n Call Back: $call \n Website: $website \n Message: $message'; 
$recipient = '[email protected]'; 
$subject = 'Fused Enterprises Contact Form'; 

$headers = "MIME-Version: 1.0" . "\r\n"; 
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; 
$headers .= 'From: <[email protected]>' . "\r\n"; 
$headers .= 'Cc: [email protected]' . "\r\n"; 

mail($recipient, $subject, $formcontent, $headers) or die("Error!"); 

echo "Thank You, the form has been submitted. Someone from the Team will contact you shortly." . " -" . "<a href='/Home/' style='text-decoration:none; color:#1e90ff;'> Return Home</a>"; 

?> 

내가 PEAR 메일을 구현해야합니까 : 여기

<form action="../../Scripts/fused.php" method="POST"><p>Name</p> <input type="text" name="name"> 
<p>Email</p> <input type="text" name="email"> 
<p>Phone</p> <input type="text" name="phone"> 

<p>Request Phone Call:</p> 
Yes:<input type="checkbox" value="Yes" name="call"><br /> 
No:<input type="checkbox" value="No" name="call"><br /> 

<p>Website</p> <input type="text" name="website"> 

<p>Message</p><textarea name="message" rows="6" cols="25"></textarea><br /> 
<input type="submit" value="Send"><input type="reset" value="Clear"> 
</form> 

는 PHP 파일입니까? 나는 그것을 구현하려고 노력했지만 이메일을받지 못했습니다. 그것이 실패하고 있는지 아닌지 나는 모른다. 스크립트가 실행되고 echo이 표시되지만 이메일을받지 못합니다. 그것은 스팸 폴더에 가지 않았다.

이 사이트는 (이 스크립트와 함께) example.com에 호스팅되지만 이메일은 smtp 서버 mail.example.com과 함께 localhost를 사용합니다. 동일한 서버에서 호스팅됩니다. 도메인 이름의 차이가 문제가 될 수 있습니까?

+0

당신이 말하는 http://ieeeaset.com/mailer/mailer.php는 "늘 보내는"당신은 오류를 준다거나 이메일을받지 않는다는 것을 의미합니까? 스팸 폴더를 확인 했습니까? –

+0

이메일을받지 못했습니다. 나는 그것이 실패하고 있는지 여부에 관해서 어떤 징후도 가지고 있지 않다. 스팸 폴더도 확인했지만 2 개의 다른 이메일로 전송되며 수신하지도 않습니다. – user1453549

+0

메일 로그를 확인하십시오. – Sammitch

답변

0

일부 호스트는 서버에서 전자 메일을 보내는 기능을 해제합니다 (따라서 서버의 스팸은 불가능합니다). 나는 그것을 맨 먼저 확인했다.

+0

나는 호스트와 함께 확인한 후 메일을 보내고, 인증이 없으며, 'localhost'를 SMTP 서버 (mail.example.com이 아닌)로 사용해야한다는 것을 알았습니다. 위 예제에서 해당 서버를 식별하는 코드를 성공적으로 구현하는 방법. – user1453549

1

HTMl 형식으로 메일을 보내려면 머리글이 가장 중요합니다. 사용이 PHP 함수 .. 내가 여기에이 스크립트를 사용하고 ...

function htmlmail() 
    { 
     if (strtoupper(substr(PHP_OS,0,3)=='WIN')) { 
      $eol="\r\n"; 
     } elseif (strtoupper(substr(PHP_OS,0,3)=='MAC')) { 
      $eol="\r"; 
     } else { 
      $eol="\n"; 
     } 
     $recmail = $_POST['toemail']; // address where you want the mail to be send 
     $sub = $_POST['subject']; //subject of email that is sent 
     $mess = $_POST['message']; 
     $pattern[0]="\'"; 
     $pattern[1]='\"'; 
     $replace[0]="'"; 
     $replace[1]='"'; 
     $mess= str_replace($pattern, $replace, $mess); 
     $headers = "From: [senders_email].$eol . 
     "MIME-Version: 1.0".$eol . 
     "Content-type: text/html; charset=iso-8859-1"; 
      mail($recmail,$sub,$mess,$headers); 
    } 
관련 문제