0

I have asked for help previously with this error:

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

Some said it was my code, so they linked solutions but they did not work. Some said it was a problem with my server, but I have tried 3 different servers. Used WAMP and now I am using easyPHP. Can anyone help me?

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>
Patrick McDermott
  • 1,220
  • 1
  • 15
  • 30
  • And did you not set `"sendmail_from" … in php.ini`? Enable the mail.log, better yet use a more workable mail class. See also: [PHP mail form doesn't complete sending e-mail](http://stackoverflow.com/q/24644436) – mario Aug 02 '15 at 12:34
  • [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 = – Patrick McDermott Aug 02 '15 at 12:40
  • ignore that one. I added the php.ini code – Patrick McDermott Aug 02 '15 at 12:42

0 Answers0