Send email [] from a website

Up Aug/03

The point of this PHP web file was to allow some of my students who did not have email accounts to send email to a class listserv. The email generated with this is thus blind - that is it uses a return address of the listserv.

The process consists of two files. One ("sendmail.php") is a form; the second ("thankyou.php") checks and processes the email, and delivers it. Both files are kept in the (web) archive directory for the listserv. In the text below, the email addresses have been converted to "listserv at domain.zone" for obvious reasons.

"sendmail.php"

It is just a form, and looks like this:

Send email From Here


Fill in your name, and add your email address, if you have one.
Type anything you wish, or import plain text files.
Skip a line between paragraphs, please.

Your name: (required)
Email address: (default)
The topic: (required)

The actual file reads as follows...


<center>
<h1>Send email From Here</h1>
</center>

<P><form ACTION="thankyou.php"> </ul> 

<br>Fill in your name, and add your email address, if you have one.
<br>Type anything you wish, or import plain text files. 
<br>Skip a line between paragraphs, please. 

<p> Your name: <INPUT type=text name=name>  (required)
<br> Email address: <INPUT type=text name=email 
value="listserv at domain.zone"> (default) 
<br> The topic: <INPUT type=text name=topic> (required)

<p> <TEXTAREA NAME=info rows="4" COLS="74" WRAP="virtual" >
</TEXTAREA>

<P>
<INPUT TYPE=reset  VALUE="[start over]">
<INPUT TYPE=submit  NAME=send VALUE="[send]">
</form>

"thankyou.php"

"Thankyou.php" checks the email for a name (required), adds the listserv email return address, and sends it to the listserv.


<center><h1>Email Accepted (or Not)</h1></center>
<hr>

<?
 // Pull data in from CGI request
$info=$_REQUEST["info"];
$topic=$_REQUEST["topic"];
$name=$_REQUEST["name"];
$send=$_REQUEST["send"];
$email=$_REQUEST["email"];

if ($send=="") {   ?>
<P><center>
<P><b>nothing to do</b>
	</center><P>
<?
        }

elseif ($info=="") {
print ("Blank message, return to sendmail.php");
        }

elseif ($topic=="") {
print ("Topic is required, return to sendmail.php file.");
	}

elseif ($name=="")  {  
print ("Name is required, return to sendmail.php file.");
	}

elseif (!$send=="")  {  
	// append to subject
$subject = "Subject_password - $topic";
	// make up headers -- others added by Procmail
if ($email=="") {
        $email = ("listserv at domain.zone");
        };
$headers =  "X-Mailer: PHP/" . phpversion() . "\r\n";
$headers .= "From: ". "$name ". "<$email> \r\n";
	// mail handling: To, subject, body, headers
 mail(  "listserv at domain.zone",
	"$subject",
	"$info",
	"$headers");
  ?> 
<pre> 
<? print ("From:  $name\n\n"); ?>
<? print ("Subject: $topic\n\n"); ?>
<? print ($info); ?>
</pre>
<hr>
<center>
<h3>Thank You</h3>
<br>
The information you posted has been sent.
</center>
<P>
<?
// end send text
	}
  ?>

The script sends the email to the address of the listserv, which does the actual redistribution. The Line "Subject_password" can be used to set a Subject-line password (which the listserv could check).


[logo]


Website Provider: Outflux.net, www.Outflux.net
URL:http://jnocook.net/geek/sendmail.htm