Keep getting an error message when I go to test my code.

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!

Moderator: General Moderators

Post Reply
bjackson
Forum Newbie
Posts: 7
Joined: Tue Aug 09, 2005 12:08 pm

Keep getting an error message when I go to test my code.

Post by bjackson »

I am running Windows 2000, I use IIS web server, and I have recently installed PHP on my computer. I went in and installed PHP in ISAPI mode.

Getting onto the problem when I do a simple test.php page and look at it online I get the following error message:

Warning: mail() [function.mail]: SMTP server response: 501 5.5.4 Invalid Address in d:\Inetpub\wwwroot\Media\testemail.php on line 2
Email test

test.php has the following code:
<?php
mail("bjackson@ids-tn.com", "Test message", "This is just a test", "From: my Server");
echo "Email test";
?>

CAN ANYBODY PLEASE HELP ME.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it says exactly what happened, an address wasn't verifiable.

Try setting a real addres for the from header.
bjackson
Forum Newbie
Posts: 7
Joined: Tue Aug 09, 2005 12:08 pm

Post by bjackson »

I am new to this feyd. I do not understand what you mean by that. Can you maybe elaborate a little.

Thanks.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

your SMTP server tried to verify the address(es) you supplied. It couldn't, so failed stating as such. You need to supply valid addresses in the fields. i.e. the "From:" header.
bjackson
Forum Newbie
Posts: 7
Joined: Tue Aug 09, 2005 12:08 pm

Post by bjackson »

I have changed the code to the following:

<?php
mail("Test message", "This is just a test", "From: bjackson@ids-tn.com");
echo "Email test";
?>

And now I have this message:

Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in d:\Inetpub\wwwroot\Media\testemail.php on line 2
Email test

Maybe this means we are getting closer. By the way sendmail_from on the php.ini states

sendmail_from = djones@ids-tn.com
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you're missing the "to" argument ... your server requires all 4 arguments.
bjackson
Forum Newbie
Posts: 7
Joined: Tue Aug 09, 2005 12:08 pm

Post by bjackson »

Please elaborate on that one I am not sure what the "to" argument is. This will probably fix my problem.
bjackson
Forum Newbie
Posts: 7
Joined: Tue Aug 09, 2005 12:08 pm

Post by bjackson »

Well I researched the "to" argument and come up with this code now.

<?php
mail('bjackson@ids-tn.com',"Test message","This is just a test","From: baj2c@mtsu.edu");
echo "Email test";
?>

Now I have this error message:

Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable to relay for bjackson@ids-tn.com in d:\Inetpub\wwwroot\Media\testemail.php on line 2
Email test
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]] )

the first argument is the to, as in the email address to send the email to. Just the address, no "Jim Jones <jjones@aolcoma.com", strictly the address.

The second argument is the subject of the email.

The third is the message (actual content) of the email.

The fourth is the headers argument. Things like the pretty "to" with the person's name, "from" address, among other header type things.
bjackson
Forum Newbie
Posts: 7
Joined: Tue Aug 09, 2005 12:08 pm

Post by bjackson »

i have done some more research and I think the problem is that bjackson@ids-tn.com is on an exchange server which requires authentication.

The Outlook that is on my web server is through my exchange server.

So all this means that I cannot get access because there is no where I can put in my password. So, it looks like I will have to get a seperate SMTP server on my Web server.

Does any of this sound right to you?

Thanks for all of your help.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

that may be true... although you should check into how IIS is set up on how to do emails and stuff..

I wouldn't entirely know, as my servers are always *nix boxes except for my test boxes.. which always run Apache.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you may want to look at phpmailer: http://phpmailer.sf.net It has some authentication connection stuff..
bjackson
Forum Newbie
Posts: 7
Joined: Tue Aug 09, 2005 12:08 pm

Post by bjackson »

Thank you for all of your help, I really appreciate it.
Post Reply