";
$line .= remove_newline( $val ) . "\t" ;
}
}
else
{
$content .= $form_mail[ $i ][ "text" ] . " \t : " . $value ."
";
$line .= remove_newline( $value ) . "\t" ;
}
}
$to=$email;
mailAttachments( $to , $subject , $content, $from) ;
if(strtolower($sWhatToDo)=="mailandfile")
{
if( ! appendToFile( $sFileName, $line ) )
die("\n\nWrite Form Mail to File Fail." );
}
if(trim($ack)!="") {
mailAutoResponse(trim($ack),$from) ;
}
}
//-------------------------------------------------------------------
function mailAutoResponse($to,$from){
global $esh_formmail_return_subject,$esh_formmail_return_msg,$email;
if( $to!="" && $esh_formmail_return_subject!="" ){
$mail = new PHPMailer();
$mail->From = $from;
$mail->FromName = "Form Module";
$mail->AddAddress($to);
$mail->WordWrap = 50;
$mail->IsHTML(true);
$mail->Subject = $esh_formmail_return_subject;
$mail->Body = nl2br($esh_formmail_return_msg);
if(!$mail->Send())
{
echo "Message could not be sent.
"; echo "Mailer Error: " . $mail->ErrorInfo; // exit; } } } //------------------------------------------------------------------------------------------ function remove_newline( $str = "" ){ //$newliner = "" ; // replace \r\n with $newliner ; //$newtaber = "" ; // replace \t with $newtaber ; $newliner = "" ; // replace \r\n with $newliner ; $newtaber = "" ; // replace \t with $newtaber ; $str = ereg_replace( "\t", $newtaber, $str ); $str = ereg_replace( "\r\n", $newliner, $str ); return ereg_replace( "\n", $newliner, $str ); } // -------------------------- Begin Mail Attachment Functions ------------------------------ function mailAttachments($to = "", $subject = "", $message = "", $from){ global $_FILES ; $mail = new PHPMailer(); $mail->From = $from; $mail->FromName = "Form Maker"; $mail->AddAddress($to); $mail->WordWrap = 50; foreach( $_FILES as $aFile ) { $sFileName = $aFile[ "tmp_name" ] ; $sFileRealName = $aFile[ "name" ] ; $mail->AddAttachment($sFileName, $sFileRealName); } $mail->IsHTML(true); $mail->Subject = $subject; $mail->Body = $message; if(!$mail->Send()) { echo "Message could not be sent.
"; echo "Mailer Error: " . $mail->ErrorInfo; // exit; } } //----------------------------------------------------------------------------- function appendToFile( $sFileName = "", $line = "" ){ if( !$sFileName || !$line ) return 0; $hFile = fopen( "$sFileName", "a+w" ); $nBytes = 0; if( $hFile ){ $nBytes = fputs( $hFile , trim($line)."\r\n" ); fclose( $hFile ); }; return $nBytes ; } ?>