I’m new to php world (actually not so much, but pretty much).
I make little block webs so I can test each feature I need. Right now I’m having trouble with the mail() function that comes with PHP, and I looked the solution up in many sites. I’ve searched here but nothing helped, every time I found some answer that seemed to work, a new problem poped up.
Let me explain my situation:
I started making some codes where I included HTML forms so I could get user info for the mail structure, the idea is to generate a kind of trace, wich the user triggers in a specific moment with some info already loaded. Later, i noticed that if I couldn’t get through with de mail() problem I wouldn’t get it to work. So I minimized my problem, and just wrote:
<?php
mail($mail, $subject, $body);
?>
Well, you can imagine, as I didn’t modify php.ini since installing xampp (which I haven’t mentioned before) I got some SMTP and sendmail_path errors;
So I looked up here and got some instructions to configure php.ini. Then tried again and nothing, it didn’t work out.
Tried with PEAR’s Mail_mime, but it just made everything blurrier, with the NON-Static problems.
Hope you can help.
I edited the php.ini file so i got
SMTP = localhost
smtp_port = 25
I am not getting any error message right now, I just don’t get an email, I also did set the from header, I forgot to point that out. I set the From header, within the phph.ini file, and when it didn’t work I edited it inside a new code’s variable. A more detailed picture would look like this:
<?php
$to = 'rojas.damian.brz@gmail.com';
$headers = array("From"=>"rojas.damian.brz@gmail.com");
$subject = 'This is the subject.';
$body = 'Here is the message.';
mail($mail, $subject, $body, $headers);
?>
That was one of the many trials.
You need to send the
Fromheader. It maybe setup to fall back to a default address, but my hunch is that it’s not. Of course, this mightn’t be the problem.mail($mail, $subject, $body, $headers);The example
Fromheader would beFrom: noreply@example.com. Separate headers in the string with\r\n.