Page 1 of 1

Mail function, need a little help.

Posted: Mon Feb 06, 2006 9:49 pm
by mattyboi
Hey guys,

I am new to this forum as well as PHP, so forgive me if this is a noob question. I used the search and tried everything I thought might be helpful but I was unsuccessful. Anyway I am just trying to send a simple email using the "mail()" fuction.

Code: Select all

<?php
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Mail it
mail("matt@sks.com", "hello", "test" ,$headers);
?>
Also, do I need any other files to make the mail() function work.

Thanks

Posted: Mon Feb 06, 2006 10:06 pm
by feyd
mail() can require several things depending on your installation. It will want a proper SMTP setting on Windows machines. It may (often does) require a From in your headers. It may not even be able to send the mail because your host disallows its users to generate emails outside of their servers. The destination may reject the email due to "bad" headers, or it just doesn't like you, or more likely, your server.

We often recommend using phpMailer instead to help quickly fix these problems and give you added functionality.

using yahoo, php.ini??

Posted: Tue Feb 07, 2006 9:00 am
by mattyboi
Thanks, I am not quite sure what do do with this though. In the instructions it tells me to edit the php.ini file. I don't know where that file is. Also I am using http://www.yahoo.com as my domian provider. Maybe that has something to do with it.

Thanks a lot.

Posted: Tue Feb 07, 2006 9:19 am
by malcolmboston
create a blank page with this code

Code: Select all

<?php
phpinfo();
?>
near the top it will say the path to your PHP.ini, copy, open up explorer, paste in address, make changes (Mail is about 2/3rd down)

go to run->type "net stop apache" without quotes -> cmd prompt should popup and close
go to run->type "net start apache" without quote

try again

Problem Solved.

Posted: Tue Feb 07, 2006 1:35 pm
by mattyboi
I solved the problem. When hosted by Yahoo, you have to turn the PHP mail function on.

Stupid Yahoo

Thanks for the help guys