Last active
September 21, 2019 21:21
-
-
Save aamahi/a0be5898461d12d20f5d7bcff8248d33 to your computer and use it in GitHub Desktop.
PHP - sending e-mail attachments.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$to = "[email protected]"; | |
$from="[email protected]"; | |
$subject = "Web Application Develoaper\n"; | |
$mainMessage ="Softwear Engineer\r\n"; | |
$fileName="./mahi.pdf"; | |
$fileNewName ="cv.pdf"; | |
$fileData = file_get_contents($filename); | |
$boundary = "Hear is Boundary"; | |
$headers = "From :{$from}"; | |
$headers .= "MIME-Version :1.0 \r\n"; | |
$headers .= "Content-type:multipart/mixed; \r\n"; | |
$headers .= "boundary = \"{$boundary}\";\r\n"; | |
$message = "This is Multipart-message\r\n"; | |
$message .= "--{$boundary}\r\n"; | |
$message .= "Content-type:text/plain; charset = UTF-8;\r\n"; | |
$message .= "Content-Transfar-Encodeing : 7bit \r\n"; | |
$message .= $mainMessage."\r\n"; | |
$encodeFileData = chunk_split(base64_encode($fileData)); | |
$message .= "--{$boundary}\r\n"; | |
$message .= "Content-type:aaplication/pdf\r\n"; | |
$message .= "name = {$fileName} \r\n"; | |
$message .= "Content-Transfar-Encodeing :base64 \r\n"; | |
$message .= $encodeFileData ."\r\n"; | |
$message .= "--{$boundary}--\r\n"; | |
$mailsend = mail($to,$subject,$message,$headers); | |
if(!$mailsend){ | |
die("Sending mail Failed\n"); | |
exit(); | |
}else { | |
echo "Mail send Sucessfully\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment