I'm having a problem using the php mail() function. I've been googling and experimenting for two days trying to figure it out to no avail.
Basically, I'm unable to send an email using the mail() function. The interesting part is that our company website (which we bought from a third party) uses the function and it works just fine. To make matters even more fun, my code works on another webserver. I've checked the php.ini sections on mail, and there dont seem to be any relevant differences.
Here is the relevant part of the company website that works:
And here is the code that won't work:
Any suggestions?
This old world keeps spinning round - It's a wonder tall trees ain't layin' down
Basically, I'm unable to send an email using the mail() function. The interesting part is that our company website (which we bought from a third party) uses the function and it works just fine. To make matters even more fun, my code works on another webserver. I've checked the php.ini sections on mail, and there dont seem to be any relevant differences.
Here is the relevant part of the company website that works:
Code:
while(list($SID, $Email) = mysql_fetch_array($sql2)) {
$unsubscribe_link = "<a href='$siteurl/obituaries.php?op=unsubscribe&Email=$Email'>here</a>";
if(ereg("\[Unsubscribe_Link\]", $mailbody)) $mailbody = ereg_replace("\[Unsubscribe_Link\]", $unsubscribe_link, $mailbody);
if((@mail($Email, $subject, $mailbody, $mailheader))) {
//echo "<font color=green>Emailed to $Email</font><br>";
} else {
//echo "<font color=red>Email failed to $Email</font><br>";
}
}
}
And here is the code that won't work:
Code:
<?php
$to = "myemailaddress";
$subject = "hello this is a test";
$message = "this is a test email";
$from = "myemailaddress";
$headers = "From: $from";
@mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
Any suggestions?
This old world keeps spinning round - It's a wonder tall trees ain't layin' down