小编inp*_*box的帖子

设置php mail()函数的SMTP详细信息

我一直在寻找答案,并尝试了许多问题.

我的脚本在我的webhost上工作正常但是当它移动到另一个专用服务器时,邮件永远不会被传递.现在我需要设置SMTP服务器,但不要正确.

使用Gmail应用程序btw.这就是代码的样子.

<?php

if(!$_POST) exit;

$email = $_POST['email'];


//$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS';
if(!eregi("@",$email )){
    $error.="Invalid email address entered";
    $errors=1;
}
if($errors==1) echo $error;
else{
    $values = array ('name','email','telephone','message');
    $required = array('name','email','telephone','message');

    $your_email = "xxx@example.com";
    $email_subject = "New Messag: ".$_POST['subject'];
    $email_content = "New message:\n";

    foreach($values as $key => $value){
      if(in_array($value,$required)){
        if ($key != 'subject' && $key != 'telephone') {
          if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
        }
        $email_content .= …
Run Code Online (Sandbox Code Playgroud)

php email smtp

11
推荐指数
2
解决办法
11万
查看次数

标签 统计

email ×1

php ×1

smtp ×1