rogerg Posted December 3, 2009 Posted December 3, 2009 I am a reseller and don't have great (ok, basically no) php skills -- there, I've started with full disclosue A developer is building a new site for one of my hosting customers and has hit a problem making php mail work -- here is what he tells me: "I may not have explained it very well. I don't have any smtp or user/pass information and I don't understand ur system very well. It might not be a "technical" issue. Here is the code I was trying to use. I get the echo but never receive an email." ><?php if(isset($_POST['sbmt'])){ $to = "someone@domain.com"; $subject = "www.**** - Contact Submission"; $email = "formmail@****" ; $message = "test message" ; $headers = "From: $email"; $sent = mail($to, $subject, $message, $headers) ; if($sent) msg = "Your mail was sent successfully"; else $msg = "We encountered an error sending your mail"; echo($msg); } ?> ******************* Can anyone give me an idea of what I should tell him -- how to point him in the right direction? Thanks, Roger Quote
OJB Posted December 3, 2009 Posted December 3, 2009 (edited) I can see a simple syntax error, you were missing the dollar sign before 'msg' after the if statement try this code: > <?php if(isset($_POST['sbmt'])) { $to = 'someone@domain.com'; $subject = 'www.**** - Contact Submission'; $email = 'formmail@****'; $message = 'test message'; $headers = 'From: $email'; if(mail($to, $subject, $message, $headers) { $msg = 'Your mail was sent successfully'; } else { $msg = 'We encountered an error sending your mail'; } echo $msg; } ?> I haven't taken a chance to properly check this code but on the face of it it seems ok. Edited December 3, 2009 by OJB Quote
rogerg Posted December 9, 2009 Author Posted December 9, 2009 Thanks -- he says it still won't work -- everything looks normal, but no mail is actually sent. Anyone have any suggestions or anything I might offer up as a suggestion for the guy doing the site work? Thanks, Roger Quote
TCH-Bruce Posted December 9, 2009 Posted December 9, 2009 You can try modifying the send line like so: >if(mail($to, $subject, $message, $headers -fsomeone@your-domain.ext) Make sure someone@your-domain.ext is a valid email address for your domain. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.