How do I send email through a remote smtp server?

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

Post Reply
james@jduncan.co.uk
Forum Newbie
Posts: 1
Joined: Tue May 28, 2002 4:53 pm

How do I send email through a remote smtp server?

Post 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
?>
User avatar
gotDNS
Forum Contributor
Posts: 217
Joined: Tue May 07, 2002 5:53 pm
Location: West Chester, PA

Post 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>
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 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
Post Reply