Page 1 of 1

sending mail, not working

Posted: Mon Mar 24, 2003 6:36 pm
by m3mn0n
This worked before for me, but since i upgraded my version of php it doesn't at all. :?
sendmail.php wrote: Warning: Failed to Connect in c:\...\...\...\sendmail.php on line 25

Code: Select all

<?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?

Thanks.

Posted: Mon Mar 24, 2003 7:17 pm
by volka
what does

Code: Select all

<?php
echo 'connecting ', ini_get('SMTP'), ':', ini_get('smtp_port');
flush();
$f = fsockopen(ini_get('SMTP'),  ini_get('smtp_port')) or die(' failed');
echo ' done';
?>
do?

Posted: Tue Mar 25, 2003 4:14 am
by mchaggis
Also, what is the smtp server setting in your php.ini.

Posted: Tue Mar 25, 2003 4:50 pm
by m3mn0n
[mail function]
; For Win32 only.
SMTP = localhost

; For Win32 only.
sendmail_from = oromian@hotmail.com

Volka:
connecting localhost: done

And i just confirmed it's not my firewall either. It must be something else...

Posted: Thu Mar 27, 2003 5:16 am
by m3mn0n
anyone?

:(

Posted: Thu Mar 27, 2003 6:02 am
by volka
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....

Code: Select all

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&#1111;0])||!gethostbyname(MailHost))
	&#123;
		return (FAILED_TO_RESOLVE_HOST);
	&#125;
...
	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...

Posted: Fri Mar 28, 2003 1:21 pm
by m3mn0n
ugh

i guess i'm stuck with a not fully functional server again.. :evil: