PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
// set up a message
$subject = "hello!";
$msg = "hi
\n
how's it going?";
$headers = "From: "Oromian" <oromian@hotmail.com>";
// connect to the database and collect addresses
require ("dbinfo.php");
$sql = "select email from emails";
$res = @mysql_query($sql) or die("Couldn't get addresses.");
// loop through the result set and send mail
while ($email_row = @mysql_fetch_array($res)) {
// get the recipient address
$to = $email_row['email'];
//send the mail
mail("$to", "$subject", "$msg", "$headers");
//print a confirmation to the screen
echo "mail sent to $to <br>";
}
?>
Line 25 is the mail() line, it can't be the code that's wrong i had the exact same version of code working on my previous php install. My current version is 4.1.1, my OS is Windows XP Pro. Did i miss a patch or some sort of setting adjustment news headline?
hm hm hm
what kind of smtp server is listening on localhost:25 ?
does it require some kind of authentication?
The only location in the php-win32-code I see that outputs such an error is sendmail.c in int TSendMail(...) when int MailConnect() returns something else than 0. And this happens here....
if ((sc = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
return (FAILED_TO_OBTAIN_SOCKET_HANDLE);
/* Get our own host name */
if (gethostname(LocalHost, HOST_NAME_LEN))
return (FAILED_TO_GET_HOSTNAME);
...
/* Resolve the servers IP */
/*
if (!isdigit(MailHostї0])||!gethostbyname(MailHost))
{
return (FAILED_TO_RESOLVE_HOST);
}
...
if (connect(sc, (LPSOCKADDR) & sock_in, sizeof(sock_in)))
return (FAILED_TO_CONNECT);
very strange that you can create a socket with php but it cannot create/connect the socket internally...