Jump to content

send mail with attach


adv

Recommended Posts

hello

i`m using this script found on google to send a mail with attachement

<?php
$strTo = "roccilaura@libero.it";  
$strSubject = "Test sending mail.";  
$strMessage = "My Body & <b>My Description</b>";  
  
//*** Uniqid Session ***//  
$strSid = md5(uniqid(time()));  
  
$strHeader = "";  
$strHeader .= "From: Mr.Weerachai Nukitram<email@email.com>\n";  
$strHeader .= "Cc: Mr.Surachai Sirisart<email@email.com>\n";  
$strHeader .= "Bcc: webmaser@email.com";  
  
$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
Share on other sites

 

//*** 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[Þ¶'±©ì±êâ}ú'¶È³{]©ÅÊ%¢¾ºëû-ÊW­i¹^Â'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
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.