'sendmail', //use sendmail , smtp or mail 'smtphost' => '', //smtp host address 'smtpauth' => 'no', //smtp authentication yes or no 'smtpusr' => '', //SMTP username 'smtppwd' => '', //SMTP password 'to_email' => 'info@pro2s.com,thuy.tran@pro2s.com', //to email address 'subject' => 'Enquiry : Request sample', //email subject 'ishtml' => 'true', //is this mail html format ); //-------------------------------------------------------------------- /** * send mail function */ function _np_sendmail($from, $data){ //get phpmailer class require(dirname(__FILE__)."/lib/smtp/class.phpmailer.php"); $mail = new PHPMailer(); //check is using smtp or sendmail] if ($data["mailer"] == "smtp"){ $mail->IsSMTP(); // set mailer to use SMTP $mail->Host = $data["smtphost"]; // specify SMTP host //check auth needed if($data["smtpauth"] == "Y"){ $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = $data["smtpusr"]; // SMTP username $mail->Password = $data["smtppwd"]; // SMTP password } } else if ($data["mailer"] == "smail"){ $mail->IsSendmail(); // set mailer to use sendmail } else { $mail->IsMail(); // set mailer to use mail } //set from email and name $mail->From = $from["coemail"]; $mail->FromName = $from["comain"]; //set reply to $mail->AddReplyTo($from["coemail"], $from["comain"]); //set to address $to = $data['to_email']; $mail->AddAddress($to); $mail->WordWrap = 60; // set word wrap to 50 characters //content type is html $html = false; if($data['ishtml']){ $mail->IsHTML(true); }else{ $mail->IsHTML(false); } // set email format to HTML //set subject $mail->Subject = $data['subject']; //get lib filter class require(dirname(__FILE__)."/lib/lib_filter.cls.php"); //loop the glove size $_glove = ''; foreach($from['cogrove'] as $k => $v){ $_glove .= $v."\n"; } $body = <<< html
Company Name : {$from['coname']}
Phone : {$from['cophone']}
Street Address : {$from['coadd']}
City/State/Zip : {$from['cocsz']}
Email : {$from['coemail']}
Website : {$from['coweb']}
Main Contact : {$from['comain']}
Title : {$from['cotitle']}
Total Number of employees : {$from['coemp']}
Glove Sizes :
{$_glove}
html;
//set body content and alt content
//filter clear html tag
$altbody = _np_getclearcontents($body);
$mail->Body = $body;
$mail->AltBody = $altbody;
error_reporting(E_ALL ^ E_WARNING);
if(!$mail->Send()) {
error_reporting(E_ALL);
return false;
}
error_reporting(E_ALL);
return true;
}
//--------------------------------------------------------------------
/**
* get request parameter
* @return param value if found else return default value
*/
function _get_param($arr, $key, $default=""){
return isset($arr[$key])? $arr[$key] : $default;
}
//--------------------------------------------------------------------
/**
* form validation
*/
function validate($val){
$valid = true;
$msg = 'Please complete the following fields:|
|
|
|