I have a very simple form on a web page taking suggestions which are emailed to me as visitors submit them. I have the php script working on PHP 4 hosting but having difficulty getting it to work on hosting with PHP 5. I've done some searching at php.net but to be honest it may as well be a foreign language to me lol. Any help would be appreciated to get this working with PHP 5. $ewho="######@######.co.uk"; $datesent=date("l dS of F Y h:i A"); $ip=$_SERVER['REMOTE_ADDR']; $subject="Submitted Suggestion"; $suggestion=$_POST['suggestion']; $mailbody ="This email was sent via the website form" . "\n\n"; $mailbody .="An idea has been submitted:" . "$suggestion" . "\n"; $mailbody .="DATE: " . "$datesent" . "\n"; $mailbody .="IP: " . "$ip" . "\n"; $body .=stripslashes($mailbody); mail($ewho,$subject,$body); PHP:
I'm not seeing an error message, just the email not turning up. Server is running Php 5.2.8 I've obviously double checked the email address. I'm wondering if I should strip the code to the most basic mail script and try that.
I've emailed my hosting company and received this back If mail() is not working I would suggest you use SMTP with an authed user/password to the mail server. This is a more elegant solution and less likely to be caught by spam traps also.
1) Yes, strip it down to something like if(mail('me@my.isp.com', 'test', 'this is the message')) { echo 'mail sent'; } else { echo 'problem sending mail'; } 2) First, they're wrong. Many SMTP hosts that allow remote connection are listed as spam sources. Second, it sounds as if they upgraded PHP and broke the mail setup. They should know what's in their php.ini file. What they should have told you is what's available on your account, not which choice you should make. If they're not set up to allow mail(), they should have said so. If they're not set up to do a direct SMTP send, they should say so. I'd ask for escalation for the problem, asking specifically what your account is set up to be able to do. Then you can decide how to send email. (If worse comes to worst, you can send email through Gmail using SMTP. Port 465 to smtp.googlemail.com, SSL/TLS security. You need a Gmail account, but it's free.)
Try sending the mail ensuring you set the 'from' address within the mail headers. I've previously had emails failing in PHP 5.3 if a from address is not set. Example: $to = 'nobody@example.com'; $subject = 'the subject'; $message = 'hello'; $headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); PHP: