Forum Moderators: coopster

Message Too Old, No Replies

How to send an email from my site?

PHP on a Windows box?

         

garann

9:34 pm on Feb 19, 2004 (gmt 0)

10+ Year Member



Hi,

My host offers PHP on their Windows server. I found a PHP script to send me email from my site, but it doesn't work because they don't have sendmail. I have no experience with PHP, so I don't know what to change so that I can send an email. Can anyone tell me where to begin?

Here's a little bit of the script:


<?php
$mail_path = "/usr/sbin/sendmail -i -t";
$mail_to = "info@example.com";
...
ini_set("sendmail_path", $mail_path);
if ($_POST)
{
if($_POST['userEmail'])
{
if( mail($mail_to,$mail_subject,"\t From: ".$_POST['userName']."\n \t Email: ".$_POST['userEmail']. "\n\n\n\n".stripslashes($_POST['userMessage']),"From: $_POST[userEmail]\r\n"."Reply-To: $_POST[userEmail]\r\n") )
{
$html = '<p>Thank you We will respond to your message shortly.</p>';
}
}
}?>

tia,
g.

Timotheos

11:51 pm on Feb 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



they don't have sendmail.

What do they use?

wruk999

12:10 am on Feb 20, 2004 (gmt 0)

10+ Year Member



just use PHP's own mail function as it doesn't require external mail server software.

I don't think sendmail is available for windows (although I could be wrong) which would mean that the script you have would only work on a Unix platform with sendmail installed.

PHP's mail function: [php.net...]

wruk999

carneddau

12:58 am on Feb 20, 2004 (gmt 0)

10+ Year Member



PHP's mail function uses sendmail as the default mailer if it is installed on the box. You can configure it to use one of the other MTAs if you so wish.

The easiest way to fix your problem is to use ini_set to change the SMTP values to that of a unix host running sendmail, you can then send mail via this box providing you have authorisation.

wruk999

10:42 am on Feb 20, 2004 (gmt 0)

10+ Year Member



From php.net:
For the Mail functions to be available, PHP must have access to the sendmail binary on your system during compile time.

Really ought to read bit more careful next time. Sorry.

Timotheos

8:03 pm on Feb 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmmm... I thought you knew something I didn't but I did find this simple instruction for using mail() on windows.
h**p://php.weblogs.com/stories/storyReader$67

Don't know if it really works especially if you cannot change php.ini but you'll have to talk to your host to get your options.