Jump to content

Recommended Posts

Posted

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

Posted (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 by OJB
Posted

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

Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...