Jump to content

mail function failure


Woody

Recommended Posts

Hey Stef,

I'm using your Tuts on PHP and when I got to the part where the mail(); function was supposed to tell me whether of not it worked...it didn't. It gave me THIS:

Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\xampp\htdocs\KillerPHP-3.php on line 26

My page is identical to yours on the video as to the coding.

So I guess you know what my question is, huh?

Wassup?

Thanks,

Wayne

Link to comment
Share on other sites

Servers can be set up differently, so that is probably why you are getting slightly different results. Also, keep in mind that if you are testing things on your local machine (using WAMP, XAMMP, MAMP, etc) rather than uploading to your web hosting and testing, you may not receive an email.

 

In order to fix your error, you can:

-- update your php.ini file (which may not be possible if your web hosting doesn't give you access to that file)

-- Or, I'd suggest setting your from header like this:

 

You would need to add this to your PHP:

 

// add this before you send the email, and update the email addresses to the ones you want to use. The "from"
// address usually has to use the same domain as the domain you are sending the email from.
$headers = 'From: webmaster@example.com' . "\r\n" .
   'Reply-To: webmaster@example.com';

// when doing the mail() function, include the "$headers" as the fourth parameter
mail($to, $subject, $message, $headers);

 

This might also be useful: http://php.net/manual/en/function.mail.php

Link to comment
Share on other sites

Thanks falkencreative!

I was playing around in the php.ini file and seem to have hit the right combination. The [mail()] function now returns a "true" response. Guess I'd better figure out what I did, huh? (actually I just uncommented a coupla lines, so I'll just comment-out those lines one at a time and see which one made the diff...unless you think that might not be the best thing to do?)

Anyway, Thanks again for your suggestions!

Woody

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
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.

Loading...
×
×
  • Create New...