这是我在 php 中自动回复电子邮件的示例代码。当我尝试发送时,他们收到的自动响应不是输出。相反,他们正在接收 HTML 代码。
<?php
$to = 'test@gmail.com';
$subject = 'persona details';
$name = $_POST['name'];
$email = $_POST['email'];
$message = "
Customer Name: $name <br/>
Email Id: $email
";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= "From:" . $email . "\r\n";
// Auto response code
$headers2 = "MIME-Version: 1.0" . "\r\n";
$headers2 .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers2 = "From:" . $to."\r\n";
$body=<<<EMAIL
<html>
<head>
<title>HTML email</title>
</head>
<body>
<h1>Sudhakar</h1>
<p><img src='http://garciniainfotech.com/images/garcinia.jpg'> </p>
</body>
</html>
EMAIL;
mail($to,$subject,$message,$headers);
mail($email,$subject,$body,$headers2);
?>