adv Posted November 28, 2011 Share Posted November 28, 2011 hello i`m using this script found on google to send a mail with attachement <?php $strTo = "[email protected]"; $strSubject = "Test sending mail."; $strMessage = "My Body & <b>My Description</b>"; //*** Uniqid Session ***// $strSid = md5(uniqid(time())); $strHeader = ""; $strHeader .= "From: Mr.Weerachai Nukitram<[email protected]>\n"; $strHeader .= "Cc: Mr.Surachai Sirisart<[email protected]>\n"; $strHeader .= "Bcc: [email protected]"; $strHeader .= "MIME-Version: 1.0\n"; $strHeader .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n"; $strHeader .= "This is a multi-part message in MIME format.\n"; $strHeader .= "--".$strSid."\n"; $strHeader .= "Content-type: text/html; charset=windows-874\n"; // or UTF-8 // $strHeader .= "Content-Transfer-Encoding: 7bit\n\n"; $strHeader .= $strMessage."\n\n"; //*** Files 1 ***// $strFilesName1 = "attach.html"; $strContent1 = chunk_split(base64_encode(file_get_contents($strFilesName1))); $strHeader .= "--".$strSid."\n"; $strHeader .= "Content-Type: application/octet-stream; name=\"".$strFilesName1."\"\n"; $strHeader .= "Content-Transfer-Encoding: base64\n"; $strHeader .= "Content-Disposition: attachment; filename=\"".$strFilesName1."\"\n\n"; $strHeader .= $strContent1."\n\n"; $flgSend = @mail($strTo,$strSubject,null,$strHeader); // @ = No Show Error // if($flgSend) echo "Mail send completed."; else echo "Cannot send mail."; ?> its sends good but one question how can i insert into the attach file values like $name $address directly from a text file Link to comment https://forums.phpfreaks.com/topic/251991-send-mail-with-attach/ Share on other sites More sharing options...
adv Posted November 29, 2011 Author Share Posted November 29, 2011 anybody please Link to comment https://forums.phpfreaks.com/topic/251991-send-mail-with-attach/#findComment-1292137 Share on other sites More sharing options...
freelance84 Posted November 29, 2011 Share Posted November 29, 2011 I have always been one for loving to write scripts from scratch just so i get a better understanding of how it all works... but i would just use phpMailer if I were you - http://phpmailer.worxware.com/ Have a look at the example scripts when you download it for attachments, pretty straight forward. Link to comment https://forums.phpfreaks.com/topic/251991-send-mail-with-attach/#findComment-1292145 Share on other sites More sharing options...
dreamwest Posted November 29, 2011 Share Posted November 29, 2011 http://www.wizecho.com/nav=php&s=email Link to comment https://forums.phpfreaks.com/topic/251991-send-mail-with-attach/#findComment-1292154 Share on other sites More sharing options...
adv Posted November 30, 2011 Author Share Posted November 30, 2011 //*** Files 1 ***// $strFilesName1 = "attach.html"; $contents = file_get_contents($strFilesName1); #$strContent1 = chunk_split(base64_encode($contents)); $strContent1 = chunk_split(base64_encode($contents)); $strHeader .= "--".$strSid."\n"; $strHeader .= "Content-Type: application/octet-stream; name=\"".$strFilesName1."\"\n"; $strHeader .= "Content-Transfer-Encoding: base64\n"; $strHeader .= "Content-Disposition: attachment; filename=\"".$strFilesName1."\"\n\n"; $strHeader .= $strContent1."\n\n"; i`m trying just to attach the file simple no distrubing the original content and i get this ²Ü¥zÜ©xÆßܲË]~‰í}©¢— +‰©Gz[Þ¶'±©ì±êâ}ú'¶È³{]©ÅÊ%¢¾ºëû-ÊWi¹^Â'm„Ú¢‚ß?Û¢·^¬zYii×bžqée²–œŠxÒÚíw?¶ò) ²·†Ûiÿû¬jø¬iÊ&þ) þZ ¢ø¬jŸÂ'm„…è †ßû]µÜ"vØ×?"š+p¶ŸÿÃ&zÖ¢®'›jy¢o♨³û™«-z·ÛrêÞr‡^¦x0‰Ûa×M!z(!´þ×mw?¶ãyÛ²Ÿíwûk¶»]r‰l¥©Þ‘žžØ¥y©šn)^–ç"£vëþšCº¶§µéZž‹-¨²Ø¨?ç(žÚ+z %j¹žž×©®ˆ+jišµ§©®‡vêÚv+Þ®'âq¦›n&¦¢¸¥zö¢éé‰Ç(–‡«®ŠÞ?émº†œr‹§µž²Ú)¢ÚÞm·ž²Ç«yÚ/ºÚŠÇ ¹éíŠj-Šø›¯U'çž×œjfâjg§¶‰Þ–W¯¢Ëkz)ߢ¹šÎ*'Š—«²‰Ú–'¬q©›Š‡bŠwb®,ó¢)ÝŠ¸³Î‡¦j)[¯bâ?Æ©iÈj Ú½çb½êâ~'æœrêÚµ©žž×¬zW³Š‰Úµ©h§8¨?çb¥¨™éí¡§ºÆ?ŠéÞ®º+z)íz¹èjYbž×«ž‡^Šz,¶¸¬ŠË^š n&¦¡«miǶ‹§iú+™¦ª¹ë-i隊VëJ*kz?ŠÇ®'襚‡n–‡¬z¢é^ŠËk»8¨ž+.–Z,r«š†ëþšM90–jºZz÷ž²Ç«yª^®Ú"žéÛ®Œ,z¹¨uêç¡È^…¢Z½«®*mi¸¥ŠÖ¡ëž×«?ëDÆ™hêÅŠ·Ÿ£^¶Ç¥æëV*kzbjj‰Ê&¦·§uêÞrª¹ë-iè+j÷®?©¢²êÚv+"rêÞÏ6?zËb?«Z¥êÜ¢{k‰»¢æ©®‹^‚«zú"yØ¥¾‹-®‡(žÚŠÇ.²&¦¢—«‚Xž½éí¹©bv+‚$ž±Ç –'yØ¢‚z+j·¥jz,¶¶«‰ÈbzËZr)Z±Èšj[kjÇ–Öœ…ë(²—§uê޵驢¶§y©žž×¢–Û¨iÇ(º{Uz¸Ÿ‰ç[ÉX¬iÊ'¶†ëþšF¬â{úiV+"Ö¥‰¤¢rêÞÏ6’ªæ?¯éþ׶»kµ×(–ÊZœnʵßí¯ûZnW what could the problem be ? and please can someone tell me the most common problems when i get this error. thanks Link to comment https://forums.phpfreaks.com/topic/251991-send-mail-with-attach/#findComment-1292578 Share on other sites More sharing options...
adv Posted November 30, 2011 Author Share Posted November 30, 2011 anybody please... Link to comment https://forums.phpfreaks.com/topic/251991-send-mail-with-attach/#findComment-1292661 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.