I use the php mail () function for a simple e-mailing process of entering the contact form to the appropriate person. The strange thing is that the form has always been used to process E-Mails, but once it all stopped, now the function returns false, but does not give any error.
The site is on a shared host. When asked about this, they recommended using smtp xx.xxx.x.xxx relay
Correct me if I am wrong, but the mail () function does not provide a provision for this? Surely the HOST device needs the correct relay configuration?
My question is: does this look like an error with the host configuration, or is this my code? Here is an example of the postal code used:
$to = " xxx@xxx.co.za "; //to who? $subject = "Website Contact: $mysubject"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "From: $fname<$email1>\r\n"; $headers .= "Reply-To: $email1\r\n"; $headers .= "Return-Path:$email1\r\n"; $headers .= "Content-Type: text/html; charset=UTF-8\r\n"; $headers .= "Content-Transfer-Encoding: quoted-printable\r\n"; $msg2 = nl2br($msg); $send = mail($to, $subject, $msg2, $headers); //process mail if(!$send): //error stuff here endif;
Thanks a lot, Simon.
@eisberg . I use my own error handler as follows:
//error handler function function customError($errno, $errstr){ $err = "\n".date('Ymd H:m:s')." Error: [$errno] $errstr"; $fh = fopen("errlog.txt", 'a+'); fwrite($fh, $err); fclose($fh); } set_error_handler("customError", E_ALL);
This means that I need to change set_error_handler("customError", E_ALL); on set_error_handler("customError", -1); ?
php email
SimonDowdles
source share