Welcome to WebmasterWorld Guest from 50.16.112.199

Forum Moderators: coopster & jatar k

Send mail and localhost

Can send mail be used locally?

   
8:17 pm on Sep 5, 2002 (gmt 0)

10+ Year Member



I want to try out some scripts that involve 'sendmail'. At the moment I can only test them by uploading to a remote server. Is there anyway to configure PHP on my windows machine to send mail so that I can test my scripts quickly?
8:26 pm on Sep 5, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As explained in [php.net...] you might try putting
SMTP = smtp.mailhost.tld
into your php.ini.
8:34 pm on Sep 5, 2002 (gmt 0)

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Yes, I remember doing that back in my <shudder>Win</shudder> days. It's very easy...

Nick

8:50 pm on Sep 5, 2002 (gmt 0)

10+ Year Member



I've tried putting my mail server in the php.ini file but my scripts still won't send. I know the scripts work as I have tested them on a unix server but am getting fed up with the constant uploading!
8:52 pm on Sep 5, 2002 (gmt 0)

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Well, great as I am, I can't guess what's wrong. Let's see the section in your ini file....

Nick

8:55 pm on Sep 5, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sendmail may be configured to not relay mail from your windows box. Whatīs the error message? Perhaps itīs a matter of POP3 before SMTP.
8:58 pm on Sep 5, 2002 (gmt 0)

10+ Year Member



Here it is!

[mail function]
; For Win32 only.
SMTP = smtp.myhost.com

I don' think this will help Nick! I think I have missed something more fundamental re. Windows/Apache and localhost.

9:04 pm on Sep 5, 2002 (gmt 0)

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Shouldn't make any differnece...

Have you tried putting that in quotes?

Nick

9:10 pm on Sep 5, 2002 (gmt 0)

10+ Year Member



As this is a bit of a mystery to me this may sound a bit dumb! How does PHP know the path to a mail client? I see that with Unix you can set a path which makes sense. How does windows/php know how to send to the mail server?
9:12 pm on Sep 5, 2002 (gmt 0)

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Because of that entry in the ini file. Have you tried quoting it?

Nick

9:16 pm on Sep 5, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



PHP doesnīt need to know the path to the MTA since it just connects to port 25 of your smtp server, which hopefully has some MTA listening on that port.

Have you tried

telnet smtp.mailhost.tld 25
to test whether there is some MTA listening? You can talk SMTP directly like this:

E:\>telnet server 25 
Trying 192.168.0.10...
Connected to server.
Escape character is '^]'.
220 berufsausbildung-online.de ESMTP Sendmail 8.11.6/8.11.0; Thu, 5 Sep 2002 23:
17:35 +0200
MAIL FROM:<root@localhost>
250 2.1.0 <root@localhost>... Sender ok
RCPT TO:<af@localhost>
250 2.1.5 <af@localhost>... Recipient ok
DATA
354 Enter mail, end with "." on a line by itself
Test
.
250 2.0.0 g85LHpt13781 Message accepted for delivery
QUIT
221 2.0.0 berufsausbildung-online.de closing connection
Connection closed by foreign host.

E:\>

If the MTA on some non-standard port you need to set that as well in your php.ini.

[edited by: andreasfriedrich at 9:20 pm (utc) on Sep. 5, 2002]

9:16 pm on Sep 5, 2002 (gmt 0)

10+ Year Member



Yep, tried that but strangely I have just run phpinfo and it does not show the change to SMTP! I have saved the change to the php.ini file so surely this should be reflected in phpinfo?
9:19 pm on Sep 5, 2002 (gmt 0)

10+ Year Member



I have tried telnet and there is a MTA listening. I think my problem stems from the php.ini file not updating.
9:21 pm on Sep 5, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you run PHP as a module you need to restart the webserver before any effect will take place.
9:23 pm on Sep 5, 2002 (gmt 0)

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Beat me to it andreas!

My moneys on that ;)

Nick

9:31 pm on Sep 5, 2002 (gmt 0)

10+ Year Member



Thank you both for your help. For some strange reason I can't get the SMTP setting to change. I think this is the root of the problem and I will have to dig a little deeper. I have restarted Apache to no avail.
9:39 pm on Sep 5, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There might be more than one php.ini on your system?

Try setting SMTP in your httpd.conf

php_value SMTP "smtp.mailhost.tld"
or
ini_set('SMTP','smtp.mailhost.tld');
from within your php script.
9:41 pm on Sep 5, 2002 (gmt 0)

10+ Year Member



I think you have hit the nail on the head. I do have two php.ini files which is obviouly causing problems....
12:50 pm on Sep 6, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is it working now?
9:31 pm on Sep 6, 2002 (gmt 0)

10+ Year Member



Yes it is thank you! The php.ini file had installed under C:\WINNT on my machine running XP Pro. I moved the file to C:\Windows, restarted Apache and bingo...

The next small problem I have is that send mail is working from my local machine but it seems to interperate scripts slightly differently and now, for example, a form that I am sending sends all the form fields along with all the variables appended to the fields. On the server it just sent the results of the fields!

Another late night...

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month