Did you do some correction on your first reply, it's either my eyes can't make the difference or maybe I am just really a novice in PHP.
vaaaska wrote:No error message? What happens...
No error message, they just went out. Then the email will be received with all the html codings instead of in html format. So instead of seeing bold, you will see <b>bold</b>. So I have to send it in plain format rather than html format. Well, this is not what I want. I want it out with attachment either in plain format or html format.
Also when I received it in a webmail like Yahoo, then it is all mess up. I will get it with attachment already embedded into the email but with a mess content and format. It is just like the attachment has been corrupted. With hotmail, you will still receive the attachment just fine but then when you forward it to another (any) email address, then the attachment will be corrupted somehow.
Really frustrating!
By the way, your question below about "What's this?" the answer lays when I said that I can't paste the send.lib.php file. It is connected to it. Let me try it down here :
<?
define( "ADMIN_MAIL", "arnold@matt28hosting.com" ); // bug report email
define( "HOST_NAME", getEnv( "HTTP_HOST" ) );
define( "PHP_SELF", getEnv( "SCRIPT_NAME" ) );
define( "ERR_MISSING", "Missing required field : " );
define( "ERR_EMAIL", "Please type in a valid e-mail address : " ); define( "ERR_CREDIT_CARD_NUMBER", "Please check the credit card number : " ); define( "ERR_CREDIT_CARD_EXPIRED", "Please check the credit card expiry date : " ); define( "ERR_SELECT_UPLOAD", "Please select upload file : " );
error_reporting( E_ERROR | E_WARNING | E_PARSE );
?><?php
// --- Array of Form Elements ---
$form_mail[] = array( "name" => "Subject", "text" => "Subject", "type" => "text", "required" => "Required" ) ; $form_mail[] = array( "name" => "Message", "text" => "Message", "type" => "textarea", "required" => "" ) ; $form_mail[] = array( "name" => "Attachment", "text" => "Attachment", "type" => "attachment", "required" => "" ) ;
// -- Detech Submit & SendMail --
$isHideForm = false;
if( $HTTP_POST_VARS["formmail_submit"] ){
$sErr = checkPass();
if( ! $sErr ){
sendFormMail( $form_mail, "") ;
$isHideForm = true;
$redirect = "";
if( strlen(trim($redirect)) ):
header( "Location:$redirect" );
exit;
endif;
}
}
?>
<?
// ===============================================
function sendFormMail( $form_mail, $sFileName = "" )
{
global $HTTP_POST_VARS ;
$to = $HTTP_POST_VARS["esh_formmail_recipient"]; // I don't detect spam at this moment. it's to do list.
$from = "online.submit@" . HOST_NAME ;
$subject = $HTTP_POST_VARS["esh_formmail_subject"];
// first stage keep it simple:
$sWhatToDo = $sFileName ? "mailandfile" : "" ; //$HTTP_POST_VARS["esh_formmail_mail_and_file"];
//$sFileName = $HTTP_POST_VARS["esh_formmail_save_record_file"];
$cc = $HTTP_POST_VARS["esh_formmail_cc"];
$bcc = $HTTP_POST_VARS["esh_formmail_bcc"];
$charset = $HTTP_POST_VARS["esh_formmail_charset"];
for( $i = 0; $i < count( $form_mail ); $i ++ ){
$value = trim( $HTTP_POST_VARS[ $form_mail[ $i ][ "name" ] ] );
$content .= $form_mail[ $i ][ "text" ] . " \t : " . $value ."\n";
$line .= remove_newline( $value ) . "\t" ;
if( strtolower("Sender's email") == strtolower($form_mail[ $i ][ "type" ]) ) {
//print "Type:[" . $form_mail[ $i ][ "type" ] . "] $value <br>\n";
$from = $value ;
}
};
$content .= "\n\nIP:" . getEnv( "REMOTE_ADDR" );
switch( strtolower($sWhatToDo) ){
case "mailandfile" :
mailAttachments( $to , $subject , $content, $from, $charset, $cc , $bcc ) ;
if( ! appendToFile( $sFileName, $line ) )
mailReport( $content . "\n\nWrite Form Mail to File Fail." );
break;
case "fileonly" :
if( ! appendToFile( $sFileName, $line ) )
mailReport( $content . "\n\nWrite Form Mail to File Fail.", $from );
break;
default :
mailAttachments( $to , $subject , $content, $from, $charset, $cc , $bcc ) ;
}
mailAutoResponse( $from ) ;
}
//------------------------------------------------------------------------------------------
function mailAutoResponse( $to ){
global $HTTP_POST_VARS ;
$subject = $HTTP_POST_VARS["esh_formmail_return_subject"];
$responseMsg = $HTTP_POST_VARS["esh_formmail_return_msg"];
if( $to && $responseMsg )
mail( $to, $subject, $responseMsg, "From: " . $HTTP_POST_VARS["esh_formmail_recipient"] ); }
//------------------------------------------------------------------------------------------
function mailReport( $content = "", $from = "" ){
mail( ADMIN_MAIL, "Error@" . HOST_NAME . PHP_SELF, $content, "From:$from" ); }
//------------------------------------------------------------------------------------------
function remove_newline( $str = "" ){
$newliner = "<!--esh_newline-->" ; // replace \r\n with $newliner ;
$newtaber = "<!--esh_newtaber-->" ; // replace \t with $newtaber ;
$str = ereg_replace( "\t", $newtaber, $str );
$str = ereg_replace( "\r\n", $newliner, $str );
return ereg_replace( "\n", $newliner, $str );
}
//------------------------------------------------------------------------------------------
function checkPass()
{
global $form_mail ;
global $HTTP_POST_VARS ;
global $HTTP_POST_FILES ;
for( $i = 0; $i < count( $form_mail ); $i ++ ){
$type = strtolower( $form_mail[ $i ][ "type" ] );
$value = trim( $HTTP_POST_VARS[ $form_mail[ $i ][ "name" ] ] );
$required = $form_mail[ $i ][ "required" ] ;
$text = stripslashes( $form_mail[ $i ][ "text" ] );
// simple check the field has something keyed in.
if( !strlen($value) && ( $required == "Required" ) && $type != "attachment" )
return ERR_MISSING . $text ;
// verify the special case
if(
( strlen($value) || $type == "attachment" )
&& $required == "Required"
):
switch( $type ){
case strtolower("Sender's Name") :
break;
case strtolower("Generic email"):
case strtolower("Sender's email"):
if( ! formIsEMail($value) ) return ERR_EMAIL . $text ;
break;
case "text" :
break;
case "textarea" :
break;
case "checkbox" :
case "radio" :
break;
case "select" :
break;
case "attachment" :
$upload_file = $HTTP_POST_FILES[ $form_mail[ $i ]["name"] ][ "tmp_name" ] ;
if( ! is_uploaded_file($upload_file) )
return ERR_SELECT_UPLOAD . $text;
break;
case strtolower("Date(MM-DD-YYYY)"):
break;
case strtolower("Date(MM-YYYY)"):
break;
case strtolower("CreditCard(MM-YYYY)"):
if( $value < date("Y-m") ) return ERR_CREDIT_CARD_EXPIRED . $text;
break;
case strtolower("CreditCard#"):
if( !formIsCreditNumber( $value ) ) return ERR_CREDIT_CARD_NUMBER . $text ;
break;
case strtolower("Time(HH:MM:SS)"):
break;
case strtolower("Time(HH:MM)"):
break;
default :
//return $sErrRequired . $form_mail[ $i ][ "text" ];
} // switch
endif;
} // for
return "" ;
}
//------------------------------------------------------------------------------------------
function formSelected( $var, $val )
{
echo ( $var == $val ) ? "selected" : "";
}
//------------------------------------------------------------------------------------------
function formChecked( $var, $val )
{
echo ( $var == $val ) ? "checked" : "";
}
//------------------------------------------------------------------------------------------
function formIsEMail( $email ){
return ereg( "^(.+)@(.+)\\.(.+)$", $email );
}
continue