PHP表单 - 邮件

时间:2015-08-02 12:21:55

标签: php forms

我之前曾要求帮助解决此错误:

Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\process.php on line 56

有人说这是我的代码,所以他们联系了解决方案,但他们没有工作。有人说这是我服务器的问题,但我尝试了3台不同的服务器。使用WAMP,现在我正在使用easyPHP。任何人都可以帮助我吗?

PHP

<?php
if (($_SERVER['REQUEST_METHOD'] == 'POST') && (!empty($_POST['action']))):

if (isset($_POST['myname'])) { $myname = $_POST['myname']; }
if (isset($_POST['mypassword'])) { $mypassword = $_POST['mypassword']; }
if (isset($_POST['mypasswordconf'])) { $mypasswordconf = $_POST['mypasswordconf']; }
if (isset($_POST['mycomments'])) {
        $mycomments = filter_var($_POST['mycomments'], FILTER_SANITIZE_STRING ); 
}
if (isset($_POST['reference'])) { $reference = $_POST['reference']; }
if (isset($_POST['favoritemusic'])) { $favoritemusic = $_POST['favoritemusic']; }
if (isset($_POST['requesttype'])) { $requesttype = $_POST['requesttype']; }

$formerrors = false;

if ($myname === '') :
    $err_myname = '<div class="error">Sorry, your name is a required field</div>';
    $formerrors = true;
endif; // input field empty

if (strlen($mypassword) <= 6):
    $err_passlength = '<div class="error">Sorry, the password must be at least six characters</div>';
    $formerrors = true;
endif; //password not long enough


if ($mypassword !== $mypasswordconf) :
    $err_mypassconf = '<div class="error">Sorry, passwords must match</div>';
    $formerrors = true;
endif; //passwords don't match


if ( !(preg_match('/[A-Za-z]+, [A-Za-z]+/', $myname)) ) :
    $err_patternmatch = '<div class="error">Sorry, the name must be in the format: Last, First</div>';
    $formerrors = true;
endif; // pattern doesn't match


if (!($formerrors)) :
    $to         =   "patrickjmcd121@gmail.com";
    $subject    =       "From $myname -- Contact/Booking Page";
    $message    =       "$myname filled out the form";
    $headers    =  'MIME-Version: 1.0' . "\r\n"; 
    $headers    .= 'From: Patrick <patrickjmcd121@gmail.com>' . "\r\n";
    $headers    .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 

    $replyto    =       "From: $email \r\n".
                                "Reply-To: mshaun.mcdermott@ntlworld.com" . "\r\n";

    if (mail($to, $subject, $message, $headers)):
        $msg = "Thanks for filling out our form";
    else:
        $msg = "Problem sending the message";
    endif; // mail form data

endif; // check for form errors

endif; //form submitted
?>

PHP.INI

 [mail function]
 ; For Win32 only.
 ; http://php.net/smtp
 SMTP = localhost
 ; http://php.net/smtp-port
 smtp_port = 25

 ; For Win32 only.
 ; http://php.net/sendmail-from
 sendmail_from = postmaster@localhost

 ; For Unix only.  You may supply arguments as well (default: sendmail -t -i).
 ; http://php.net/sendmail-path
 ;sendmail_path =</code>

0 个答案:

没有答案