Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Copyright © Amirol Zolkifli & SistemBorang.com
- Author: Amirol Zolkifli
- URL: http://fb.com/amirolzolkifli
- License: For your personal use only
- */
- require 'mail/PHPMailerAutoload.php';
- require 'borang-konfigurasi.php';
- // Validate form submission
- if( ! isset( $_POST['form_submit'] ) OR $_POST['form_submit'] != 'true' )
- {
- $error = 'Sila isi borang dengan lengkap.';
- include 'borang-error.php';
- exit();
- }
- // Define variables
- $customer_name = $_POST['customer_name'];
- $customer_email = $_POST['customer_email'];
- $customer_phone = $_POST['customer_phone'];
- $customer_address = $_POST['customer_address'];
- $model_kereta = $_POST['model_kereta'];
- // Validation
- $error = '';
- if( $customer_name == '' )
- {
- $error .= 'Sila isi nama anda<br /><br />';
- }
- if( $customer_email == '' )
- {
- $error .= 'Sila isi alamat emel anda<br /><br />';
- }
- if( $customer_phone == '' )
- {
- $error .= 'Sila isi nombor telefon anda<br /><br />';
- }
- if( $customer_address == '' )
- {
- $error .= 'Sila isi alamat rumah anda<br /><br />';
- }
- if( $model_kereta == '' )
- {
- $error .= 'Sila pilih model kereta anda<br /><br />';
- }
- if( $error != '' )
- {
- $error = 'Error with your form. Please go back.';
- include 'borang-error.php';
- exit();
- }
- // Set email
- $email_subject = 'Terima kasih untuk email anda';
- $email_content = "
- Terima kasih untuk kiriman borang.
- <br /><br />
- Berikut adalah data kiriman borang daripada $customer_name;
- <br /><br />
- =========================
- <br /><br />
- Nama: $customer_name
- <br />
- Email: $customer_email
- <br />
- No. Telefon: $customer_phone
- <br />
- Alamat:
- <br />
- $customer_address
- <br /><br />
- Model Kereta: $model_kereta
- <br />
- <br />
- <br />
- <br />
- Sila rujuk attachment dibawah ini:
- ";
- // Process form
- $mail = new PHPMailer;
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = $mail_host; // Specify main and backup SMTP servers
- $mail->SMTPAuth = $mail_auth; // Enable SMTP authentication
- $mail->Username = $mail_username; // SMTP username
- $mail->Password = $mail_password; // SMTP password
- $mail->SMTPSecure = 'tls';
- $mail->From = $email_from;
- $mail->FromName = $customer_name;
- $mail->addAddress($email_replyTo, $email_name); // Add a recipient
- $mail->addReplyTo($customer_email, $customer_name);
- $mail->addCC($customer_email, $customer_name);
- // Attachment
- if( isset($_FILES['attachments']) )
- {
- $name_array = $_FILES['attachments']['name'];
- $tmp_name_array = $_FILES['attachments']['tmp_name'];
- $type_array = $_FILES['attachments']['type'];
- $size_array = $_FILES['attachments']['size'];
- $error_array = $_FILES['attachments']['error'];
- for($i = 0; $i < count($tmp_name_array); $i++){
- $mail->AddAttachment( $tmp_name_array[$i], $name_array[$i]);
- }
- }
- $mail->isHTML(true); // Set email format to HTML
- $mail->Subject = $email_subject;
- $mail->Body = $email_content;
- $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
- if( !$mail->send() ) {
- echo 'Message could not be sent.';
- echo 'Mailer Error: ' . $mail->ErrorInfo;
- } else {
- header('location: '. $thankyou_page);
- }
- ?>
Add Comment
Please, Sign In to add comment