homepage Welcome to WebmasterWorld Guest from 54.161.192.130
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Send mail and localhost
Can send mail be used locally?
cyclic

10+ Year Member



 
Msg#: 1172 posted 8:17 pm on Sep 5, 2002 (gmt 0)

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?

 

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1172 posted 8:26 pm on Sep 5, 2002 (gmt 0)

As explained in [php.net...] you might try putting
SMTP = smtp.mailhost.tld
into your php.ini.
Nick_W

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



 
Msg#: 1172 posted 8:34 pm on Sep 5, 2002 (gmt 0)

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

Nick

cyclic

10+ Year Member



 
Msg#: 1172 posted 8:50 pm on Sep 5, 2002 (gmt 0)

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!

Nick_W

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



 
Msg#: 1172 posted 8:52 pm on Sep 5, 2002 (gmt 0)

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

Nick

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1172 posted 8:55 pm on Sep 5, 2002 (gmt 0)

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.

cyclic

10+ Year Member



 
Msg#: 1172 posted 8:58 pm on Sep 5, 2002 (gmt 0)

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.

Nick_W

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



 
Msg#: 1172 posted 9:04 pm on Sep 5, 2002 (gmt 0)

Shouldn't make any differnece...

Have you tried putting that in quotes?

Nick

cyclic

10+ Year Member



 
Msg#: 1172 posted 9:10 pm on Sep 5, 2002 (gmt 0)

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?

Nick_W

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



 
Msg#: 1172 posted 9:12 pm on Sep 5, 2002 (gmt 0)

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

Nick

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1172 posted 9:16 pm on Sep 5, 2002 (gmt 0)

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]

cyclic

10+ Year Member



 
Msg#: 1172 posted 9:16 pm on Sep 5, 2002 (gmt 0)

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?

cyclic

10+ Year Member



 
Msg#: 1172 posted 9:19 pm on Sep 5, 2002 (gmt 0)

I have tried telnet and there is a MTA listening. I think my problem stems from the php.ini file not updating.

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1172 posted 9:21 pm on Sep 5, 2002 (gmt 0)

If you run PHP as a module you need to restart the webserver before any effect will take place.

Nick_W

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



 
Msg#: 1172 posted 9:23 pm on Sep 5, 2002 (gmt 0)

Beat me to it andreas!

My moneys on that ;)

Nick

cyclic

10+ Year Member



 
Msg#: 1172 posted 9:31 pm on Sep 5, 2002 (gmt 0)

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.

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1172 posted 9:39 pm on Sep 5, 2002 (gmt 0)

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.
cyclic

10+ Year Member



 
Msg#: 1172 posted 9:41 pm on Sep 5, 2002 (gmt 0)

I think you have hit the nail on the head. I do have two php.ini files which is obviouly causing problems....

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1172 posted 12:50 pm on Sep 6, 2002 (gmt 0)

Is it working now?

cyclic

10+ Year Member



 
Msg#: 1172 posted 9:31 pm on Sep 6, 2002 (gmt 0)

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...

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved