Page 1 of 2
Can NOT send email
Posted: Sun May 04, 2003 1:45 am
by doodle
I can NOT send email using PHP from my computer. I installed Windows2000, IIS, PHP. I can send email using ASP. How com? help please!!!!!!
Posted: Sun May 04, 2003 2:40 am
by reverend_ink
Can you post the code you are using to send from?
May make it easier to help out.....
Posted: Sun May 04, 2003 12:37 pm
by doodle
<?
mail ($to, $subject, $mailbody);
?>
Thank you very much. I am looking forward to hearing from you again.
Doodle
Posted: Sun May 04, 2003 12:49 pm
by evilmonkey
Your e-mail settings in php.ini might be misconfigured. Check phpinfo() and go from there. You might have configured PHP not to use mail at all. Alternatively, you can try to install SquirrelMail. If that doens't work, you know something is up with the PHP settings.
Good luck,
Evil Monkey.
Posted: Mon May 05, 2003 1:10 am
by doodle
Hi,
I checked the php.ini It seems no problem. I am tearing off my hair. oohh
Doodle
Posted: Mon May 05, 2003 1:21 am
by skylavelle
This one has worked for me.
Code: Select all
<?
mail($toText, $subjectText, $msgText, "To: $toText <someone@somewhere.com>\n" . "From: $fromText <$fromText>\n" . "X-Mailer: PHP 4.x");
?>
Cheer
Sky
Posted: Mon May 05, 2003 1:25 am
by lcidw
In your php.ini..
Code: Select all
;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;
(..)
їmail function]
; For Win32 only.
SMTP = localhost
; For Win32 only.
sendmail_from = me@localhost.com
make sure your smtp server is defined right. localhost would only work if you had a mailSERVER running. try putting your provider's smtp server there. And i don't know if or how the sendmail_from really works, if the above didn't work try commenting it.
Posted: Mon May 05, 2003 11:24 pm
by doodle
Hi, Thanks your guys.
I tried every possibilities. It seems the bus between PHP and Windows NT.
I newly installed WinXP Professional with IIS and PHP. All I use are default settings. It still doesn't work. I can NOT send email from PHP.
oops.
Thank you anywhere
Maybe I should give up tying and stop using PHP.
doodle
Posted: Tue May 06, 2003 3:45 am
by twigletmac
Have you edited your php.ini as suggested by lcidw? If you don't tell PHP where to find the SMTP server then the mail() function will not work.
Go to your php.ini, it's in the WINDOWS directory, open it in Notepad and find the lines lcidw posted and edit them. You can usually use your ISPs SMTP server (e.g. the one you have setup for your e-mail) for the SMTP value and then you just need to change the sendmail_from address to your e-mail address.
Not all of PHP works straight out of the box, there are tiny things like this that you need to configure yourself.
Mac
Posted: Tue May 06, 2003 8:21 am
by skylavelle
Do what twigletmac suggests and checkout your php.ini file.
If you are still having problems I can post mail.php, which will work!
Let me know
Sky
Posted: Tue May 06, 2003 9:58 am
by volka
Also check wether there is a smtp server where you expect it to be.
Installing IIS does not necessarily mean the mail server has been set up properly (if you want to use it as your MTA)
php.ini wrote:[mail function]
; For Win32 only.
SMTP = localhost
whatever
SMTP is set to in your php.ini try to connect to that host via telnet. The default port is 25 but might have been re-configured in recent versions of php, e.g.
Code: Select all
їmail function]
; For Win32 only.
SMTP = just.another-ho.st
smtp_port = 125
taking the default values (localhost:25) you might try
- open a console on your win32-box
- type telnet localhost 25
there should be a response
220 ...<something about smtp or esmtp>....
If not or a connection error occurs there is no mail server running and php isn't to blame

Next step would be to check the mail server's configuration. Is it able to transfer the mails?
Posted: Tue May 06, 2003 1:01 pm
by doodle
Hi,
Thank you all.
I checked the php.ini file. It looks like what you said. everything is fine.
It like the following:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[mail function]
; For Win32 only.
SMTP = localhost ; for Win32 only
; For Win32 only.
sendmail_from =
me@localhost.com ; for Win32 only
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
I opened a console on your win32-box and typed telnet localhost 25. The following appears on the console.
-----------------------------------
220 ..... ready .....
-----------------------------------
It seems good
I can send email using ASP by object "CDONTS.NewMail" to whatever hotmail or yahoo.
but when I tried using PHP, some times the following Warning appears:
---------------------------------------------------------
Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable to relay for
doodleyang@canada.com in F:\Web\email.php on line 8
---------------------------------------------------------
Thank you all again. Please help me again.
Doodle
Posted: Tue May 06, 2003 1:44 pm
by volka
by default IIS does not allow mail to be relayed through it to an external mail address.
You can change these settings via directory security->relay restrictions in the managment console to enable relaying for localhost.
But take care you're not making it an open relay spammers might use.
Posted: Tue May 06, 2003 2:12 pm
by doodle
Thanks, Volka
Where and how to open Directory Security?
Thanks again.
Doodle
Posted: Sat May 10, 2003 12:38 am
by doodle
Help me again??? Where to change that???