<?php
// $email are the data that is being
$sch_email = $_REQUEST['sch_email'];
$sch_tel = $_REQUEST['sch_tel'] ;
$sch_address = $_REQUEST['sch_address'] ;
$sch_fax = $_REQUEST['sch_fax'] ;
$sch_panel = $_REQUEST['sch_panel'] ;
$panel_tel = $_REQUEST['panel_tel'] ;
$sch_email_incharge= $_REQUEST['sch_email_incharge'] ;
$sch_incharge= $_REQUEST['sch_incharge'] ;
$sch_incharge_tel= $_REQUEST['sch_incharge_tel'] ;
$sch_tea_email= $_REQUEST['sch_tea_email'] ;
$std_name_01= $_REQUEST['std_name_01'] ;
$class_q_01= $_REQUEST['class_q_01'] ;
$std_tel_01= $_REQUEST['std_tel_01'] ;
$std_email_01= $_REQUEST['std_email_01'] ;
$title_01= $_REQUEST['title_01'] ;
$question_01= $_REQUEST['question_01'] ;
$guide_tea_01= $_REQUEST['guide_tea_01'] ;
$std_name_02= $_REQUEST['std_name_02'] ;
$class_q_02= $_REQUEST['class_q_02'] ;
$std_tel_02= $_REQUEST['std_tel_02'] ;
$std_email_02= $_REQUEST['std_email_02'] ;
$title_02= $_REQUEST['title_02'] ;
$question_02= $_REQUEST['question_02'] ;
$guide_tea_02= $_REQUEST['guide_tea_02'] ;
$std_name_03= $_REQUEST['std_name_03'] ;
$class_q_03= $_REQUEST['class_q_03'] ;
$std_tel_03= $_REQUEST['std_tel_03'] ;
$std_email_03= $_REQUEST['std_email_03'] ;
$title_03= $_REQUEST['title_03'] ;
$question_03= $_REQUEST['question_03'] ;
$guide_tea_03= $_REQUEST['guide_tea_03'] ;
$std_name_04= $_REQUEST['std_name_04'] ;
$class_q_04= $_REQUEST['class_q_04'] ;
$std_tel_04= $_REQUEST['std_tel_04'] ;
$std_email_04= $_REQUEST['std_email_04'] ;
$title_04= $_REQUEST['title_04'] ;
$question_04= $_REQUEST['question_04'] ;
$guide_tea_04= $_REQUEST['guide_tea_04'] ;
$std_name_05= $_REQUEST['std_name_05'] ;
$class_q_05= $_REQUEST['class_q_05'] ;
$std_tel_05= $_REQUEST['std_tel_05'] ;
$std_email_05= $_REQUEST['std_email_05'] ;
$title_05= $_REQUEST['title_05'] ;
$question_05= $_REQUEST['question_05'] ;
$guide_tea_05= $_REQUEST['guide_tea_05'] ;
$std_name_06= $_REQUEST['std_name_06'] ;
$class_q_06= $_REQUEST['class_q_06'] ;
$std_tel_06= $_REQUEST['std_tel_06'] ;
$std_email_06= $_REQUEST['std_email_06'] ;
$title_06= $_REQUEST['title_06'] ;
$question_06= $_REQUEST['question_06'] ;
$guide_tea_06= $_REQUEST['guide_tea_06'] ;
$button01 =$_REQUEST['button01'];
$jun_class_num =$_REQUEST['jun_class_num'];
$button02 =$_REQUEST['button02'];
$sen_class_num =$_REQUEST['sen_class_num'];
$content .= "--$mime_boundary--\r\n";
// ADD FILE
if ($_FILES{"attach01"}{"name"} != "")
{
$file = $_FILES{"attach01"}{"tmp_name"};
$file_name = $_FILES{"attach01"}{"name"};
$content_type = $_FILES{"attach01"}{"txt"};
$fp = fopen($file, "rb");
$data = fread($fp, filesize($file));
$data = chunk_split(base64_encode($data));
$content .= "Content-Type: $content_type; name=$file_name\r\n";
$content .= "Content-Disposition: attachment; filename=$file_name\r\n";
$content .= "Content-Transfer-Encoding: base64\r\n\r\n";
$content .= "$data\r\n";
}
require("/home/abc/public_html/phpmailertesting/PHPMailer_5.2.0/class.phpmailer.php");
$mail = new PHPMailer();
$mail->CharSet = 'utf-8';
$mail->Encoding = "base64";
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "smtp.gmail.com"; // specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "ABC@GMAIL.COM"; // SMTP username
$mail->Password = "XXXX"; // SMTP password
$mail->SMTPSecure = "tls";
$mail->Port = 587; // TCP port to connect to
$mail->From =
$mail->FromName = " System";
$mail->AddAddress ("$sch_email","School Email"); // name is optional
$mail->AddAddress ("$sch_tea_email","Teacher");
$mail->AddReplyTo =
$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = abc;
?>
Actually i created the site for questionnaire event, Using mailer sends the data to default email after finishing the questions. Email is functionally smooth.
But , the email without attachment by user uploading file, Could anyone help me solve , i would be much appreciated. Thanks!
Spend a week to solve this problem that include attachment by user submitting
Message shown “Could not access file: PLEASE CHECK Email.”