basic php email code - need help


#1

Hi,
Im new at this, so sorry if the problem is extremely simple.

I am hosting my website (http://www.iiinc.us) through godaddy.com and I am trying to use php to make a simple feedback form. As a test, I used the following code (saved to in a file test.php) to see If I could send email from their server:

<?php $to="d_lazaro@hotmail.com"; $subject="test"; $body="Just testing the email script."; $headers="From: http://www.iiinc.us/test.php, I got the second message, so obviously something is wrong. I tried searching for answers and many tutorials and sites mentioned that i might have to use ini_set() to set the SMTP and the sendmail_from configurations. I tried calling tech support to ask for the smtp server, and they told me that I didnt have to do anything, just write correct code and upload it to my main directory, which I did. I also asked for help with my email script, but they said they couldnt answer those type of questions.

My questions: So am I missing something in the code? Do the parameters to the mail() function matter, or are they just text for the email message. Also maybe Im asking the wrong questions to tech support, so they’re giving me answers to the wrong problem.
Any help would be greatly appreciated.

Thanks,
Del


#2

I would do a couple of things… echo out everyone one of your variables to make sure they are exactly as you expected. Next I would try using rn at the end of the $header string rather then just n. maybe even break it up into baby steps so we can isolate the problem.
[php]
$to="d_lazaro@hotmail.com";
$subject=“test”;
$body=“Just testing the email script.”;
$headers=“From: pilar.lazaro@iiinc.usrn”;
// debugging here
// echo out values
echo $ton$subjectn$bodyn$headers;
// send mail
$sent = mail($to,$subject,$body,$headers)

if($sent) {
echo “An e-mail was sent to $to with the subject: $subject.”;
}
else {
echo “There was a problem sending the mail.”;
}
[/php]

Just a few suggestions. No guarentees.


#3

Thanks for the suggestion.

Ill try it out.