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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mail() function Win2K - Help! 1

Status
Not open for further replies.

squidster

Technical User
Oct 13, 2002
55
GB
Hi,

I have been trying to get mail sending from my test server (win2K, running Apache1.3.27, php4.2.3) but just get error:-

Warning: Failed to Receive in c:\phpdev\ on line 2

My php.ini has been amended to show the right bits:-
[tt]
[mail function]
; For Win32 only.
SMTP = relay.plus.net

; For Win32 only.
sendmail_from = me@here.co.uk
[/tt]

and am using a simple test script:-

[tt]
<?php
mail ('them@there.co.uk', 'No need for reply -- PHP test!', 'Can you se me?\nLine 2\n');
?>[/tt]

Can anyone help?

thanks

squidster;)
 
Ok, have managed to get this working after installing a mailserver on my test server.

Also had to change php.ini to:-

SMTP = localhost

but the mailserver still uses the ISP domain IP.

I know this isn't really programming but would be nice to know why it didn't work the other way round, if anyone knows.

Anyways, just in case anyone else has problems, try installing a mail server, I've gone with ArGoSoft, which seems pretty simple and basic, just right for testing.

bye
 
It can be difficult to debug PHP email problems stictly from within PHP. You don't get a good enough picture of what is going on.

A technique I use when debugging email problems, regardless of the environment in which I detect the problem, is to use telnet.

I telnet on port 25 to the offending server, then by-hand issue the commands necessary to inject a message into the system. Often, the specific error messages reported by the server give me a better picture of what is going on than the general error messages reported by an application. Want the best answers? Ask the best questions: TANSTAAFL!
 
Thanks sleipnir214,

I know how to use telnet as far as connecting but I'm afraid I'm at a loss as to issueing commands for email.

I've tried to connect to relay.plus.net (and using their IP) but can't even open the connection??

This is definately the correct DSN as it's the same in my email client.

??
 
The conversation between a mail server and mail client reads something like the following. Responses from the server are in blue, responses from the client in green.

<initial greeting from mail server beginning with the number 220>
mail from: <youremail@somedomain.com>[enter]
<response from server beginning with the number 250>
rcpt to: <recipient@anotherdomain.com>[enter]
<response from server beginning with the number 250>
data[enter]
<response from server beginning with the number 354>
From: Your Name <youremail@somedomain.com>[enter]
To: Your Recipient's Name <recipient@anotherdomain.com>[enter]
Subject: Your Subject[enter]
[enter]
testing[enter]
.[enter]
<response from server beginning with the number 250>
quit[enter]
<response from server beginning with the number 221>

Notes:[ul][li]The triangle brackets (&quot;<&quot;, &quot;>&quot;) around the email addresses need to be there. Some servers do not require them on the &quot;mail from:&quot; and &quot;rcpt to:&quot; lines, but will accept them if you do, so always use them.[/li][li]When you enter the command &quot;data&quot;, the server will not respond until it receives a period (&quot;.&quot;) on a line by itself -- this signifies the message has been completed.[/li][li]The string &quot;[enter]&quot;, of course, signifies hitting the enter key at the end of a line[/li][/ul] Want the best answers? Ask the best questions: TANSTAAFL!
 
Mmmm, kind of interesting, not sure if its supposed to work like that but I ended up typing the commands without them appearing back to the screen, just the replies.

Kind of like a leap of faith?

Anyway here's what the server said:-

220 netmail02.services.quay.plus.net - Plus.Net, The smarter way to Internet - E
SMTP
250 ok
250 ok
354 Please start mail input.
250 Mail queued for delivery.

Which to me sounds as though there's no problems with the server so we're back to a problem with mail()?

But then why does it work with localhost via the mailserver?


 
I thought about that so tried setting php.ini with:-

max_execution_time = 90 (was 30)

and

SMTP = 212.159.11.150 (was relay.plus.net)

but still get same error:-

Warning: Failed to Receive in c:\phpdev\ on line 5

my mail script is now:-
[tt]
<?php
$to = &quot;testing@gwyds.co.uk&quot;;
$subject = &quot;No need for reply -- PHP test!&quot;;
$content = &quot;hi John\nLine 2\n&quot;;
mail (&quot;$to&quot;, &quot;$subject&quot;, &quot;$content&quot;);
?>
[/tt]

The only thing I can think of now is that mail() doesn't set a port No so maybe it never opens the connection? But when useing the mailserver it uses the correct protocol and port.

Can't see anything in the .ini for this, I tried tagging the port No on the end of SMTP setting but still no go:(

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top