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

mail works in outlook but not with mail()

Status
Not open for further replies.

hwangee

Technical User
Jan 27, 2005
7
GB
I have set up my pc as a web server using apache2triad.

Everything runs fine for my web but having problems using the mail() function.

I have setup my email account in outlook to test it and I can send mail to a friends hotmail and receive mail back fine.

however like I said everytime I use mail() to send something it just doesn't work.

If the mail() is sending to my email address on my server it works ok though.

using windows xp
php.in configured as follows.

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

I've also tried

[mail function]
; For Win32 only.
SMTP = smtp_port = 25

but still nothing goes outside my LAN.

If I couldn't send/receive from outlook I might understand a little more but I'm not sure how that works and mail() doesn't.

I'm new to php and was wondering if there was some small detail I'm missing.

Here's one of the many attempts.

$email = mail ( "my_email@hotmail.com", "Please work", "Running out of hair very rapidly",
"From: admin@
Any advice would be appreciated (Big time)
 
When you say that the address works with Outlook, are you running Outlook on the same machine as the one running PHP?

If so, what is the outgoing mail server setting in Outlook, and have you used that setting as the "SMTP" setting in php.ini?

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
outlook is on another PC on the LAN.

in php.ini I used both localhost and my domain name and both worked through lan but none outside lan.

However after thinking about what you asked I setup outlook on the same pc as the server and noticed in add remove programs>windows components that SMTP was not ticked.

I have installed this and outlook and tried still doesn't work on same pc as server.

I've changed so many things trying to learn what I need to do I'm getting confused.

installing the server using the triad install I can set it all up in minutes so I think I might reinstall it and start again.

What I would like is any advice on anything I need to do to configure mail as I seem to be missing something
 
I don't think reinstalling is necessary. First and foremost, you need a mail server, which doesn't come installed by default on Win32.

On the other machine from which you tried Outlook, with what outgoing mail server is Outlook working? Have you used that server in the SMTP setting of php.ini?

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
the outgoing mail server I used was
(Obviously mydomain being my DNS, I'm sure someone somewhere at some time has actually put mydomain instead LOL)

this was the same as the pop3 setting.

I have changed the SMTP = to this and it still worked only on LAN when using mail().

since my first post I've done something and the mail doesn't even work with outlook now so thats why I think I'll reinstall so that all settings will be returned to default
 
What I mean is

the mail() function is only working when sent to my admin@mydomain.co.uk email but failing when sent to any email outside my LAN.

This is the initial problem.

I have reinstalled apache2triad and put website back and working ok.

with all the default settings outlook will only email to emails on LAN.

Then when I look in PHPXmail under server domains I have one called
There is a link there called pop3.

when I use this to add a pop3 email address the mail now works from outside my LAN.

Not sure if this is the problam but the pop3 email I am adding is the same as the default for php to send. I first thought this was adding the pop3 ability to this email but if it is somehow creating another with the same name maybe php is still using the lan one.

I sound like I'm babbling now, hope you understatnd
 
This sounds like an SMTP server security setting issue.

If PHP will send an email to a local address, then PHP is working correctly.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
found a site where I enter my
IP address, email to send to and email to send from and it tests it all.

result was

SMTP Connection:
OK, connected to 217.42.***.***...
< 220 <1106868066.4036@ [XMail 1.20 ESMTP Server] service ready; Thu, 27 Jan 2005 23:21:06 -0000
> HELO edit.dnsvr.com
< 250 > MAIL FROM:<admin@< 250 OK
> RCPT TO:<email I used@hotmail.com>
< 550 Relay denied

when searching further it seems that the mail() function doesn't support mail authenticasion (Is this correct)

any ideas.
 
PHP's mail function does not.

At times like these, I heartily recommend PHPMailer, a PHP email class. It supports many advanced email features, including SMTP authentication.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
OK further searching through numerous forums and finally working.

seems I simply needed to add a line to the smtprelay.tab

"127.0.0.0"[TAB]"255.255.255.0"[RETURN],

also made sure in php.ini

SMTP = localhost

sendmail_from = postmaster@
working at last.

I think the main problem was that there's just so many settings that can be changed I lost my way at some point.

Anyway thanks for all your help I am really greatfull.

Can finally now get the member login running on my site with users able to verify their email

Thanks agan!!!!!!!!!!!!!!!
 
Sorry I meant

"127.0.0.1" "255.255.255.0"[RETURN],


hehehe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top