Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我的脚本似乎无法工作,建议使用SMTP吗?_Php_Html_Post - Fatal编程技术网

Php 我的脚本似乎无法工作,建议使用SMTP吗?

Php 我的脚本似乎无法工作,建议使用SMTP吗?,php,html,post,Php,Html,Post,首先,我正在学习PHP,我还在初级阶段,(对不起)。我有一个脚本,在填写表单后给我发送电子邮件。表单位于另一个页面上,这是一个发挥所有魔力的页面。由于某种原因,这个代码不起作用,我根本没有收到电子邮件。因为我错过了什么 多谢各位 <?php if(!$_POST) exit; // Verifico email. function isEmail($email) { return(preg_match("/^[-_.[:alnum:]]+@((([[:alnum:]]

首先,我正在学习PHP,我还在初级阶段,(对不起)。我有一个脚本,在填写表单后给我发送电子邮件。表单位于另一个页面上,这是一个发挥所有魔力的页面。由于某种原因,这个代码不起作用,我根本没有收到电子邮件。因为我错过了什么

多谢各位

    <?php

if(!$_POST) exit;

// Verifico email.
function isEmail($email) { 
    return(preg_match("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i",$email));     
}

if (!defined("PHP_EOL")) define("PHP_EOL", "\r\n");

$name     = $_POST['name'];
$email    = $_POST['email'];
$subject  = $_POST['subject'];
$comments = $_POST['comments'];
$verify   = $_POST['verify'];

if(trim($name) == '') {
    echo '<div class="error_message">Attention! You must enter your name.</div>';
    exit();
} else if(trim($email) == '') {
    echo '<div class="error_message">Attention! Please enter a valid email address.</div>';
    exit();

} else if(!isEmail($email)) {
    echo '<div class="error_message">Attention! You have enter an invalid e-mail address, try again.</div>';
    exit();
}

if(trim($subject) == '') {
    echo '<div class="error_message">Attention! Please enter a subject.</div>';
    exit();
} else if(trim($comments) == '') {
    echo '<div class="error_message">Attention! Please enter your message.</div>';
    exit();
} else if(!isset($verify) || trim($verify) == '') {
    echo '<div class="error_message">Attention! Please enter the verification number.</div>';
    exit();
} else if(trim($verify) != '4') {
    echo '<div class="error_message">Attention! The verification number you entered is incorrect.</div>';
    exit();  
}

if(get_magic_quotes_gpc()) {
    $comments = stripslashes($comments);
}


// Configuracion.

$address = "abc@xyz.com";
$addressrrhh = "abc@xyz.com";
$e_subject = 'You\'ve been contacted by ' . $name . '.';

// Campos del form ampliables.

$e_body = "You have been contacted from JACK contact form by $name with regards to $subject, their additional message is as follows." . PHP_EOL . PHP_EOL;
$e_content = "\"$comments\"" . PHP_EOL . PHP_EOL;
$e_reply = "You can contact $name via email, $email";

$msg = wordwrap( $e_body . $e_content . $e_reply, 70 );

$headers = "From: $email" . PHP_EOL;
$headers = "BCC: $addressrrhh" . PHP_EOL;
$headers .= "Reply-To: $email" . PHP_EOL;
$headers .= "MIME-Version: 1.0" . PHP_EOL;
$headers .= "Content-type: text/plain; charset=utf-8" . PHP_EOL;
$headers .= "Content-Transfer-Encoding: quoted-printable" . PHP_EOL;

if(mail($address, $e_subject, $msg, $headers)) {

    // Mensaje envio OK

    echo "<fieldset>";          
    echo "<div id='success_page'>";
    echo "<h1>Email Sent Successfully.</h1>";
    echo "<p>Thank you <strong>$name</strong>, your message has been submitted.</p>";
    echo "</div>";
    echo "</fieldset>";

} else {

    echo 'ERROR!';

}
?>


请看一看,首先

我认为使用SMTP比其他方式更好。如果您在使用mail()函数时遇到问题,也许可以看看PEAR:PEAR.php.net

Post是完全不同的。它不像荷兰语单词post,意思是mail:D

$\u POST是一个存储POST表单发送的所有值的变量。例如:使用POST方法的表单有一个名为“foo”的输入文本字段。在该字段中键入:“bar”并提交该字段后,将创建一个$\u POST数组,其中$\u POST[“foo”]的值为“bar”

也许您读过一些关于不使用php的on mail()函数而更好地使用SMTP的内容?这就有点道理了

祝你好运

  • 在Web服务器错误日志中提交时是否有错误

  • 你的邮件寄出去了吗?(查看您的邮件日志)

  • 如果是,它是否在您的垃圾邮件文件夹中

  • 关于直接标记为垃圾邮件的邮件 事情“改变”了一点,你不能只发送一封电子邮件而不设置“第五个”参数,否则你的邮件将直接发送到垃圾邮件箱

    还有,我建议你做一个很好的编剧

    用法示例:


    希望它能帮助你,你完全误解了这一点。“我被告知,$\u POST不太好用,因为电子邮件可以发送到垃圾箱等。”这是完全错误的。
    我被告知,$\u POST不太好用,因为电子邮件可以发送到垃圾箱等
    -你被告知错了。他们彼此无关。不管是谁告诉你这对他们自己和其他人都是一种危险…$\u POST与邮件进入垃圾文件夹无关我认为有人在和Arther玩得很开心。毕竟,如果我想发送邮件,我会通过邮局发送。非常感谢,我请求帮助。非常感谢,我请求帮助。非常感谢,我请求帮助。好的,谢谢你。所以我的问题是,在看了你提供的链接之后。我上面的剧本怎么样。它是有缺陷的或糟糕的编码,还是只是缺少一些基本的东西?我只需要知道,这样我就可以在上面的脚本工作或从头开始。谢谢你。你能回答我的三个问题吗?这样我或其他人就可以帮助你了。好的,我正在尝试访问Web服务器错误日志。这是我的第一步。我能回答的第三个问题是,垃圾邮件中没有任何东西。会让你不断更新的..嗨。好啊我想我已经发现了问题所在。该域已转移到gamil以使用其服务。我登录到c面板,发现一个装满邮件的邮箱。“邮件传递失败:将邮件返回给发件人”。这就解释了为什么邮件没有被发送,因为MX记录指向GMAIL系统。最好的办法是让上面的脚本发送电子邮件?非常感谢。
    The additional_parameters parameter can be used to pass additional flags as command line options to the program configured to be used when sending mail, as defined by the sendmail_path configuration setting. For example, this can be used to set the envelope sender address when using sendmail with the -f sendmail option.
    
    The user that the webserver runs as should be added as a trusted user to the sendmail configuration to prevent a 'X-Warning' header from being added to the message when the envelope sender (-f) is set using this method. For sendmail users, this file is /etc/mail/trusted-users.