kmccmk9 Posted October 14, 2014 Share Posted October 14, 2014 Hello, so I have been able to successfully use the imap_mail_compose function to generate a valid and working MIME message string. However, when trying to add an attachment, the MIME message never contains the attachment., What am I doing wrong? $envelope["from"]=$_SESSION['username']; $envelope["to"]=$_POST['To']; $envelope["cc"]=$_POST['Cc']; $envelope["bcc"]=$_POST['Bcc']; $envelope["subject"]=$_POST['Subject']; $part1["type"] = TYPEMULTIPART; $part1["subtype"] = "mixed"; $part2["type"]=TYPETEXT; $part2["subtype"]="plain"; $part2["contents.data"]=$_POST['Message']; $uploaddir = "C:\\inetpub\\wwwroot\\PHPTesting\\uploads\\"; $uploadfile = $uploaddir.$_FILES['Attachment']['name']; move_uploaded_file($_FILES['Attachment']['tmp_name'], $uploadfile); $fp = fopen($uploadfile, "r"); $contents = fread($fp, filesize($uploadfile)); fclose($fp); $part3["type"] = $_FILES['Attachment']['type']; $part3["encoding"] = ENCBINARY; $part3["description"] = basename($uploadfile); $part3["contents.data"] = $contents; $body[1]=$part1; $body[2]=$part2; $body[3]=$part3; $mime = imap_mail_compose($envelope, $body); Quote Link to comment https://forums.phpfreaks.com/topic/291623-php-imap_mail_compose-with-attachments-help/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.