Koozali.org: home of the SME Server

sending mail using PHP script

Offline billi

  • *
  • 46
  • +0/-0
    • http://applitec.net
sending mail using PHP script
« on: September 24, 2004, 09:24:38 AM »
Has anyone sent mail from a PHP page to a remote user?
What is the correct syntax for the PHP.INI file to get mail to be sent?
http://www.php.net/manual/en/function.mail.php is the help site for the mail command.

Here is a sample that might work.

<html>
<head><title>Feedback</title></head>
<body>

<?php

// Handle POST method.
if ($_POST)
{
 $name = $_POST['name'];
 $email = $_POST['email'];$comments = $_POST['comments'];

 // Compose simple text message:
 $message = "Message from $name ($email)\n\nComments:\n\n$comments";

 // Send message to billir@hotmail.com
 mail("billir@hotmail.com", "Feedback", $message);

 // Thank the generous user
 echo "<h1>Cheers!</h1>\n";
 }
 else
 {

 ?>

 <h1>Feedback</h1>

 <form action="<?= $PHP_SELF ?>" method="post">

 <p>Name: <input type="text" name="name" /></p>

 <p>Email: <input type="text" name="email" /></p>

 <p>Comments:</p>
 <p><textarea name="comments"></textarea></p>

 <p><input type="submit" value="Send!" /></p>

 </form>

 <?php

 }

 ?>

Offline byte

  • *
  • 2,183
  • +2/-0
sending mail using PHP script
« Reply #1 on: September 24, 2004, 09:31:20 AM »
This might be better off posted in a php forum as nothing to do with SME Server :roll:
--[byte]--

Have you filled in a Bug Report over @ http://bugs.contribs.org ? Please don't wait to be told this way you help us to help you/others - Thanks!

Offline warren

  • *
  • 293
  • +0/-0
sending mail using PHP script
« Reply #2 on: September 27, 2004, 09:07:38 PM »
Something along these lines works for me :( set the html form variables )

the php code :
 <p><?
$toaddress  "somebody@somedom.com";
      $subject = "Feedback";
      $mailcontent =    "Name: ".$_REQUEST["name"]."\n"
      ."Surname: ".$_REQUEST["surname"]."\n"
      ."Respond: ".$_REQUEST["respond"]."\n"
      ."Email: ".$_REQUEST["email"]."\n"
      ."Cell: ".$_REQUEST["cell"]."\n"
      ."Tel: ".$_REQUEST["tel"]."\n"
      ."Subject: ".$_REQUEST["subject"]."\n"
      ."Name: ".$_REQUEST["message"]."\n";
      $fromaddress = $_REQUEST["email"];
      mail ($toaddress,$subject,$mailcontent,$fromaddress);?></p>


Rgds

Warren