ok
Direktori : /home2/selectio/public_html/sqarextechnologies.com/shrivaariagencies.in/ |
Current File : /home2/selectio/public_html/sqarextechnologies.com/shrivaariagencies.in/send-email.php |
<?php $to = "srivaariagenciesslm9@gmail.com"; $subject = "Subject of the email"; $message = "Body of the email"; // Boundary for marking the attachment $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; // Headers for attachment $headers = "From: hariharanravichandran1@gmail.com\r\n" . "Reply-To: hariharanravichandran1@gmail.com\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: multipart/mixed; boundary=\"{$mime_boundary}\""; // Add the email body $message = "--{$mime_boundary}\r\n" . "Content-Type: text/plain; charset=\"UTF-8\"\r\n" . "Content-Transfer-Encoding: 7bit\r\n\r\n" . $message . "\r\n"; // Attach the file $file_path = "/path/to/your/file.txt"; $file_contents = file_get_contents($file_path); $file_base64 = base64_encode($file_contents); $message .= "--{$mime_boundary}\r\n" . "Content-Type: application/octet-stream;\r\n" . " name=\"" . basename($file_path) . "\"\r\n" . "Content-Description: " . basename($file_path) . "\r\n" . "Content-Disposition: attachment;\r\n" . " filename=\"" . basename($file_path) . "\"; size=" . filesize($file_path) . ";\r\n" . "Content-Transfer-Encoding: base64\r\n\r\n" . $file_base64 . "\r\n"; $message .= "--{$mime_boundary}--"; // Send the email $mail_success = mail($to, $subject, $message, $headers); if ($mail_success) { echo "<script> alert('Email sent successfully with attachment...'); window.location.href='form.php'; </script>"; } else { echo "<script> alert('Failed to send email...'); window.location.href='form.php'; </script>"; } ?>