[mail function]
SMTP = mymailserver.example.com
Tag Archives: mail
ezmlm
ezmlm is a software package for managing electronic mailing lists by Daniel J. Bernstein. It is similar to GNU Mailman and Majordomo but only works with the qmail mail transfer agent. It is released into the public domain.The latest version, 0.53, came out in 1997. The ezmlm-idx patches add modern features like MIME handling.
ezmlm provides all of the common electronic mailing list functionality: moderated lists, automated subscription and unsubscription, and digest creation. ezmlm takes advantage of the features of qmail to enable ordinary users to create and to manage mailing lists, without need for superuser privileges .
Example
<?php
$headers = “MIME-Version: 1.0n”;
$headers .= “Content-type: text/html; charset=iso-8859-1n”;
$headers .= “From: from@phpcodez.comn”;
$headers .= “Return-Path: info@phpcodez.comn”;
$headers .= “Return-Receipt-To: info@phpcodez.comn”;
@mail(“info@phpcodez.com”,”Test”, “Test Mail”, $headers);
?>
ezmlm_hash
It calculates the hash value needed by EZMLM
Example
<?php
echo $hash = ezmlm_hash(“info@phpcodez.com”);
?>
Output
5
Mail functions
- ezmlm_hash() – It calculates the hash value needed by EZMLM
- mail() – It can be used to send email
Contact us form – PHP
<?php
//PHP Code to send mail using the data from contact form
extract($_POST);
if(isset($_POST[‘send’])){
//Validation contact form fields
if(preg_replace(“/^s*$/”,””,$firstname)==”” )
$errorList[]=”Select the department name is required.”;
if(preg_replace(“/^s*$/”,””,$email)==”” )
$errorList[]=”Email is required.”;
elseif(!eregi(“^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$”, $email))
$errorList[] = “Email address is invalid.”;
if(preg_replace(“/^s*$/”,””,$message)==”” )
$errorList[]=”Message is required.”;
//If no error send mail
if(count($errorList)==0){
$toAddres = “mail@example.com”; //Give desired emaill address to whcih mail has to be sent
$subject = “Contact from – Your Site Name”;
$headers = “MIME-Version: 1.0n”;
$headers .= “Content-type: text/html; charset=iso-8859-1n”;
$headers .= “From: “.$email.”n”;
$headers .= “Return-Path: “.$toAddres.”n”;
$headers .= “Return-Receipt-To: “.$toAddres.”n”;
$mailMessage = ‘<table width=”687″ >
<tr><td width=”161″>Hi Admin</td><td width=”7″></td><td width=”561″></td></tr>
<tr><td width=”161″></td><td width=”7″></td><td width=”561″></td></tr>
<tr><td width=”161″>Name</td><td width=”7″></td><td width=”561″>’.$firstname.'</td></tr>
<tr><td width=”161″>Message</td><td width=”7″></td><td width=”561″>’.$message.'</td></tr>
<table>’;
@mail($toAddres,$subject, $mailMessage, $headers); $success=5; } }?>
// Contact form
<form action=”#” method=”post”>
<table>
<?php if(count($errorList)>0){ ?>
<tr>
<td> </td><td><div style=”margin:5px; color:#FF0000;”><?php foreach($errorList as $value) echo $value.” ,”; ?></div></td></tr>
<?php } ?>
<?php if($success==5){ ?>
<tr>
<td> </td> <td><div style=”margin:10px; color: #006633; width:90%; clear:none; float:left; font-weight:bold”>Your message has been sent to site admin .</div></td>
</tr>
<?php } ?>
<tr>
<td>Please enter your <strong>name</strong>:</td> <td><input name=”firstname” type=”text” value=”<?php echo $firstname ?>” /></td>
</tr>
<tr>
<td>Please enter your <strong>email address </strong>:</td> <td><input name=”email” type=”text” value=”<?php echo $email ?>” /></td>
</tr>
<tr>
<td>Please enter message:</td> <td><textarea name=”message” style=”height:50px;”><?php echo nl2br($message); ?></textarea></td>
</tr>
<tr>
<td> </td> <td><input type=”submit” name=”send” value=” Send “></td>
</tr>
</table>