我突然发现我的联络场不工作了。意味着我很可能在去年丢失了很多电子邮件..。哇哦。
你能帮我看看是怎么回事吗?
我是100%,当我测试它在一年前,但也许在代码或浏览器设置中的一些东西已经改变了。
我在电子邮件里查过我的垃圾邮件,什么都没有。
它在Wordpress中,我为此做了一个插件。
<?php
/*
Template Name:Haugsdalen_kontakt
*/
?>
<?php get_header(); ?>
<div id="left" class="eleven columns" >
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<?PHP haugsdalen_kontaktplugin(); ?>
</div>
<?php endwhile; endif; ?>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>如果很难理解这种语言,很抱歉,但我想您只会查看代码。
<?php
/**
* Plugin Name: Haugsdalen Skisenter Kontaktskjema
* Description: Kontaktskjema for Haugsdalen Skisenter
* Version: 1.0
* Author: Ole Andreas Vekve
* License: GPL2
Copyright 2013 KANDIDATNUMMER 902
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
function test_input_kontakt($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
function haugsdalen_kontaktplugin () {
function haugsdalen_kontakt_header () {
echo ('<link rel="stylesheet" type="text/css" href="'.plugin_dir_url( __FILE__ ).'haugsdalen-kontakt.css">');
}
$from = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$to = 'ole.andreas.vekve@gmail.com';
$subject = 'Ny melding fra Haugsdalen Skisenter';
$body = "Ny melding fra Haugsdalen Skisenter:\n Fra: $name\n E-post: $email\n Melding:\n $message";
echo ('<div id="kontakthead">');
if ($_POST['submit']) {
if (mail ($to, $subject, $body, $from)) {
echo '<p>Din melding har blitt sendt!</p>';
} else {
echo '<p>Noe gikk galt. Vennligst prøv igjen.</p>';
}
}
echo ('<form method="post" action="http://haugsdalen.com/kontakt/">
<h2>Kontakt</h2>
<label>Navn</label>
<input name="from" placeholder="Ditt navn">
<label>E-post</label>
<input name="email" type="email" placeholder="Din e-post">
<label>Melding</label>
<textarea name="message" placeholder="Din melding..."></textarea>
<input id="submit" name="submit" type="submit" value="Send inn"></form><br/>
<h3><strong>Kontaktinformasjon:</strong></h3>
Tlf: 73 85 46 05<br/>
E-post: ole.andreas.vekve@gmail.com<br/>
</div>');
}
?>发布于 2015-01-09 11:23:13
$from变量是if (mail ($to, $subject, $body, $from))中的标头部分,其中邮件将其用作默认的From:,而$from = $_POST['name'];则是一个“名称”。邮件是阅读“从:”作为一个名称。它必须是一个电子邮件地址。
正因为如此,许多电子邮件客户端会将其解释为垃圾邮件,或者干脆放弃。
邮件正在以John@inexistant_user_on_yourserver.xxx的形式读取/解释它,因此返回到xxx@your_hosting_provider_mail.xxx作为"From:“而不是john@his_email_service.xxx
您需要将该变量更改为$email,以便您的代码现在读为
if (mail ($to, $subject, $body, $email))有关此问题的更多信息,请阅读手册:
因此,您可以添加:
$header = "From: ". $from . " <" . $email . ">\r\n";然后将其更改为:
if (mail ($to, $subject, $body, $header))它将显示来自某个名称的邮件,同时仍然是一个有效/格式正确的电子邮件地址。
略作编辑:
您在$name中还有一个未定义的变量$body,它应该是$from,因为这是名称部分,正如$from = $_POST['name'];那样,但是在查看表单的元素<input name="from" placeholder="Ditt navn">之后,它在语言中的意思是" name“。
需要更改为$from = $_POST['from'];
或更改<input name="from" placeholder="Ditt navn">
转到<input name="name" placeholder="Ditt navn">
https://stackoverflow.com/questions/27859355
复制相似问题