Can NOT send email

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

doodle
Forum Newbie
Posts: 11
Joined: Sun May 04, 2003 1:45 am

Can NOT send email

Post 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!!!!!!
reverend_ink
Forum Contributor
Posts: 151
Joined: Sun Apr 20, 2003 1:18 am
Location: Las Vegas | London

Post by reverend_ink »

Can you post the code you are using to send from?

May make it easier to help out.....
doodle
Forum Newbie
Posts: 11
Joined: Sun May 04, 2003 1:45 am

Post by doodle »

<?
mail ($to, $subject, $mailbody);
?>

Thank you very much. I am looking forward to hearing from you again.


Doodle
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post 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. :D

Good luck,

Evil Monkey.
doodle
Forum Newbie
Posts: 11
Joined: Sun May 04, 2003 1:45 am

Post by doodle »

Hi,

I checked the php.ini It seems no problem. I am tearing off my hair. oohh


Doodle
User avatar
skylavelle
Forum Newbie
Posts: 18
Joined: Sun May 04, 2003 11:33 pm
Location: Brisbane, Australia

Post by skylavelle »

This one has worked for me. :D

Code: Select all

<?
mail($toText, $subjectText, $msgText, "To: $toText <someone@somewhere.com>\n" . "From: $fromText <$fromText>\n" . "X-Mailer: PHP 4.x");
?>
Cheer
Sky
lcidw
Forum Commoner
Posts: 58
Joined: Mon Apr 28, 2003 8:55 am
Location: Netherlands

Post by lcidw »

In your php.ini..

Code: Select all

;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;

(..)

&#1111;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.
doodle
Forum Newbie
Posts: 11
Joined: Sun May 04, 2003 1:45 am

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Last edited by twigletmac on Tue May 06, 2003 9:22 am, edited 1 time in total.
User avatar
skylavelle
Forum Newbie
Posts: 18
Joined: Sun May 04, 2003 11:33 pm
Location: Brisbane, Australia

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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

&#1111;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?
doodle
Forum Newbie
Posts: 11
Joined: Sun May 04, 2003 1:45 am

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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.
doodle
Forum Newbie
Posts: 11
Joined: Sun May 04, 2003 1:45 am

Post by doodle »

Thanks, Volka

Where and how to open Directory Security?

Thanks again.

Doodle
doodle
Forum Newbie
Posts: 11
Joined: Sun May 04, 2003 1:45 am

Post by doodle »

Help me again??? Where to change that???
Post Reply