Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not receiving email from basic PHP emailing script??

Status
Not open for further replies.

JoJoH

Programmer
Joined
Jan 29, 2003
Messages
356
Location
US
Hi all,

Hum weird, I am very new to PHP and I am totally puzzled about this situation:

I have this very basic script, no error...

<?php
$to = &quot;myemail@ssomewhere.com&quot;;
$subject = &quot;Hi!&quot;;
$body = &quot;Hi,\n\nHow are you?&quot;;
if (mail($to, $subject, $body))
{
echo(&quot;<p>Message sent!</p>&quot;);
}
else
{
echo(&quot;<p>Message delivery failed...</p>&quot;);
}
?>

But when I send and recieve from my Outlook, no emails coming in... All the OTHER email from other people came in fine just the once sent from my php script... Any ideas? Thanks!

JoJoH

 
re u connected to the net? check ur SMTP settings in php.ini...

Known is handfull, Unknown is worldfull
 
Also are you specifying any 'from address'?
Try
Code:
$headers = &quot;From:fromaddress@ursite.com&quot; ; 

if (mail($to, $subject, $body,$headers))
.....

do u have some SMTP filter on ur server.
The filter rejects junk ' from addresses ' from receiving so be carefull abt 'from address' u specify.
If ur using Windows based server seperate ur headers by &quot;\r\n&quot; rather than only &quot;\n&quot;.



--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
i dont think that is necessary...

Known is handfull, Unknown is worldfull
 
Thanks guys for the replies!

Even this script, with all the required info doesn't work:

<?php
$to=&quot;<someone@example.com>&quot;;
$headers =&quot;From: someone-else@example.com&quot;;
$headers .= &quot;MIME-Version: 1.0rn&quot;;
$headers .= &quot;Content-type: text/html; charset=iso-8859-1rn&quot;;
$subject =&quot;Regarding whatever&quot;;
$body=&quot;<html><head></head><body><b>Big Bold HTML Message</b></body></html>&quot;;
// Now we send the message
//We set a variable equal to the mail() function in order to capture success or fail.
$send_check=mail($to,$subject,$body,$headers);


if ($send_check!=true)
{
echo 'An error occurred while sending mail.';
die();
}
?>

And how do I &quot;check ur SMTP settings in php.ini&quot;?

Please advice.

Thanks in advance!

JoJoH

 
Then the SMTP settings in php.ini for servername, etc., don't apply.

How are you testing your script? What is the domain name of the address to which you are sending email?

It could be that the script is correctly sending the mail, but some antispam or other problem is blocking delivery.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
yeah SMTP is for windows... i think the best for linux is sendmail...

Known is handfull, Unknown is worldfull
 
Thanks sleipnir214, vbkris for the replies!

I've test this and other php emailing script on both a windows(my web host) and a linux(my client's web host) server, and I am sending it to myself...Still am not getting the emails...so weird

Please advice

Thanks!

JoJoH

 
Lots of things can stop email delivery.

One is antispam efforts. The mail servers for the domain name of your address may be refusing the email. Earthlink.net, for example, is pretty picky.

It could be that neither machine's SMTP sending capabilities are working. Incorrect server DNS setup, incorrect PHP SMTP settings, and other things can cause this problem.

As a first step, I'd find another email address to send to for testing.



Want the best answers? Ask the best questions: TANSTAAFL!!
 
I sent one to a hotmail account but still nothing shows up... also, I am wondering, is my web host responsible for the PHP SMTP settings? Please advice

Thanks!

JoJoH

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top