Page 1 of 1

How do I send email through a remote smtp server?

Posted: Tue May 28, 2002 4:53 pm
by james@jduncan.co.uk
Hi
I am "extreeeeeemly" new to php - so please, go easy on me! I have been reading books and looking through existing php scripts on the net and want to create a form that will submit the details to the site administrator, send a copy of the form to the person that filled it in and give a visual copy on the screen - eg> Thank you for your submission. You asked for :
1 xchocolate sundae with hazelnut sauce
3 x honey nut fudge cakes with gooey pecan drizzle.

I can work out the echo of the submission to screen (although still have not got it to work), but my mail problem is that I can not send email as my email server is on a different machine.

If it helps/ makes any difference - we are running Mac OSX with apache PHP4 and the mail server is webstar 4.2 (on different ip address).

Any help / ideas much appreciated.
Regards
James
?>

Posted: Tue May 28, 2002 5:05 pm
by gotDNS
help?:

Code: Select all

<?php
$connect = mysql_connect("localhost:3306", "techy") && mysql_select_db("forum")
or $failed = "Could not connect to database.";
?>

<html>
<head>
<title>Techy Board</title>
<link rel="stylesheet" type="text/css" href="default.css" />
</head>
<body marginheight="0" marginwith="0" topmargin="0" leftmargin="0">
<?php
$TO = "you@you.you";
$HEADER = "From: techy@techy.techy\r\n";
$HEADER .= "Bcc: $sendto\r\n";
   //send mail - $subject & $contents come from surfer input
   mail($TO, $SUBJECT, $MESSAGE, $HEADER);
   // redirect back to url visitor came from
?>
Newsletter sent! <a href="index.php">< Home</a>
</body>
</html>

Posted: Wed May 29, 2002 1:56 am
by twigletmac
Have you added the address of your SMTP server to the SMTP directive in the php.ini file? If you have check out:
http://www.php.net/manual/en/function.mail.php

Mac