从我的表单收到的电子邮件正在显示我的主机

时间:2012-05-21 23:17:22

标签: php forms wordpress email contact

我的WP 3.1安装上有这个小小的设置,它应该是一个很好的联系表格。

问题在于,当我收到电子邮件时,它显示的是我的webhosts服务器名称而不是“myemail@mydomain.com”。

有什么办法可以纠正吗? 并且还有一个“向我发送副本”功能,我想将其用作BCC以保持清洁。 谢谢你提前!

这是我的sendmail.php “

require_once("../../../../wp-load.php");

$mail = addslashes($_POST["mailForm"]);
$mail = nl2br($mail);

$from_mail = addslashes($_POST['from_mail']);

$to = wpts_get_option("general", "contact_email");

/* subject */
$subject = "New Contact Message - ATOM";

/* message */
$message = $mail;

/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

/* and now mail it */
if(@mail($to, $subject, $message, $headers))
{
?>
    <div class="success">
    <div class="box-content"><?php _e("Done! We'll contact you in few moments!", 'atom'); ?></div>
    <div class="clearboth"></div>
    </div>
<?php
}
else
{
?>
    <div class="error">
    <div class="box-content"><?php _e("Oh, sorry! Something wrong... Please, try again.", 'atom');?></div>
    <div class="clearboth"></div>
    </div>
<?php
}

&GT?; “ 这是我的sendorder.php “

require_once("../../../../wp-load.php");

$myemail = wpts_get_option("ordernow", "order_email");

$name = addslashes($_POST["name"]);
if($name == '') {
?>
    <div class="error">
    <div class="box-content"><?php _e("Please insert your name.", 'atom'); ?></div>
    <div class="clearboth"></div>
    </div>
<?php
exit;
}

$email = addslashes($_POST["email"]);
if($email == '') {
?>
    <div class="error">
    <div class="box-content"><?php _e("Please insert a email address.", 'atom'); ?></div>
    <div class="clearboth"></div>
    </div>
<?php
exit;
}

$finalOrder = nl2br( addslashes($_POST["finalOrder"]) );

$uploads = addslashes($_POST["uploads"]);

$files = explode(";", $uploads);
$uploads = '';

for($i = 0; $i < count($files); $i++) {
    $uploads .= '- <a href="'.$files[$i].'" target="_blank">'.$files[$i].'</a><br />';
}

$message = str_replace("uploads_here", $uploads, $finalOrder);

/* subject */
$subject = "New Order/Quote Request";

/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

$to = $myemail.','.$email;

/* and now mail it */
if(@mail($to, $subject, $message, $headers))
{
?>
    <div class="success">
    <div class="box-content"><?php _e("Done! You'll receive a order copy in your email.", 'atom'); ?></div>
    <div class="clearboth"></div>
    </div>
<?php
}
else
{
?>
    <div class="error">
    <div class="box-content"><?php _e("Oh, sorry! Something wrong... Please, try again.", 'atom');?></div>
    <div class="clearboth"></div>
    </div>
<?php
}

&GT?; “

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题。它出现在我的[login_name] @ [mysever]。

尝试调整标题。

我是从http://php.net/manual/en/function.mail.php

中提取的
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";

希望这就是你所需要的。