Added: 2 years ago
From: optikalefxx
Views: 12,756
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (93)

Sign In or Sign Up now to post a comment!
  • Fantastic Job........

  • Wasting of my time

    why you did not Attached the source file :(

  • great vid, great tutorial... got it workin on my system thanks to you.

  • Question, is it possible to send an attachment to someone that can't be forwarded to someone else?

  • @dbmrhi nope sorry

  • THankss man!! 

  • God bless you man!

  • whats wrong with this code pastebin com/tddssFpA

  • @Szegi87 you have some off characters on line 30, you have Mime instead of MIME.  And your $extension var is in all quotes, but thats PHP you have inside of there?

  • @optikalefxx ii sends email but filename is always something like that "/tmp/phpGst0z8" and the size is 0kb

  • @Szegi87 Thats because you didn't move the uploaded file to your computer first. You need to use move_file_upload first, then use that location as the file

  • @optikalefxx is there another way? i mean just send email with attachment without putting it on my hosting server?

  • @Szegi87 just do unlink($file) afterwards

  • I'm getting the same error as Rygap, and I'm also a windows user. $replyto is never defined, and I changed it to $to even though I never saw this guy change it. Perhaps linux does treat things differently and you can't just use windows with a local email server with this code.

  • @obesechicken13 Also, it'd be nice to actually put the source code up somewhere.

  • Thank you so much for the code! I was looking for one that worked for sometime. Please make all the code available on your website or blog. It will save some people a lot of headaches and problems !

  • If I try to use this script with .mp3 attachments it cuts the track length down to 7 seconds. Any idea why?

  • after posting the form with the php script on one page I get this resolt on the attach.php page:

    Warning: mail() [function.mail]: Bad parameters to mail() function, mail not sent. in /home/content/d/e/d/dedwards72­7/html/attach.php on line 140

    fail. looking forward to your help. Thanks in advance.

  • after posting the form with the php script on ane page I get this resolt on the attach.php page:

    Warning: mail() [function.mail]: Bad parameters to mail() function, mail not sent. in /home/content/d/e/d/dedwards72­7/html/attach.php on line 140

    fail. looking forward to your help. Thanks in advance.

  • Under the comments //standard mail headers You use a variable named - $replyto - that is not declared anywhere. I imagine that it is just a typo, but I didnt see it corrected. Anyway, what would we use there instead $to or $from ?

    For windows users try downloading PostCastServer it works pretty decent

  • Can anyone help, The Code did not work? for me

  • Hey optikalefxx - thanks for this video. It works really well and is just what I wanted. I did have one question though: how can you get it to upload the file to a folder on the server once it has been sent (in case it needs to be redownloaded)? I have tried and can get it to up load with the if(move_uploaded_file($_FILES[­'attachment']['tmp_name'], $target)), but I can get it to send the mail. I can get it to send the mail but not upload to server. Do you have any suggestions on how to do this?

  • i cannot thank you enough.

  • hey man, thanks for the video. it works great with gmail but i can't get it to work with hotmail or yahoo mail, could you please help me with this. any help would be greatly appreciated. THANKS IN ADVANCE

  • hi,

    I tried doing the exact same thing.

    But when i receive and email, instead of an image or document I receive a garbage value.

    I am really new to PHP ..please help!!!!!!!!

  • Thanks a lot for making and uploading this video. You helped me really a lot!

    One question: how should I rewrite the codes if I want to have 2 or more files?

  • @molnarcsilla just separate each file by the attachment boundry. i wanna do a video on this soon, so if you can't figure it out persay - keep an eye out for that video.

  • @optikalefxx can't wait :) thanks in advance

  • @optikalefxx I gave it up :) but no problem..

    other question: how can I setup two e-mail addresses where the data to be sent?

    is it possible to put the second email address to bcc? if yes, how? thanks in advance

  • Comment removed

  • Hey this script does not work on godaddy hosting. the mail function is not working in it. Can u check into this.

  • Hey this code does not work in a godaddy host. The mail function does not support godaddy . can u check into this

  • @chaseranster85858 don't use godaddy - get a better host provider. OR, call godaddy because I know it does work with them. You probably aren't paying them enough.

  • Everything works fine, except for one thing. It doesn't show the message in het e-mail? Does anybody knowwhat the solution is?

    I have the following: $header .= "--".$uid."\r\n"; $header .= "Content-type:text/plain; charset=UTF8\r\n"; $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n"; $header .= $message."\r\n\r\n";

  • @mrtentje double and tripple check you have exactly the right thing, look at the other video i did on this as a troubleshooting and tips.

  • Everything's working fine except gmail. E-mails sent this method aren't received by gmail.com . Any solutions will be appreciated :-)

  • hey so I'm sry to say but I'm another person with a problem! lol

    but any ways I'm constantly getting the please enter the right file type message even when I attach the right file type! I have checked my code and all seams right?!?! any ideas? thank u in advanced

    -Daniel

  • Comment removed

  • Hey, I know you must be really busy with all that you do. But I could really use your help with this form. I'm receiving the same error as "lingachannel" (2 months ago):

    Warning: file_get_contents(...) [function.file-get-contents]: failed to open stream: No such file or directory in /home/...thank_you.php on line 205

    The email sends and I receive an attachment, but it's always 0kb and can never be accessed. Would you be able to help me with this?

    Thank you,

    Danice

  • @studdnature I was also receiving the attachments with 0kb and then I found out that I was missing the last line of the following block:

    $header .= "--".$uid."\r\n";

    $header .= "Content-Type: ".$file_type."; name=\"".$file_name."\"\r\n";

    $header .= "Content-Transfer-Encoding: base64\r\n";

    $header .= "Content-Disposition: attachment; filename=\"".$file_name."\"\r\­n\r\n";

    $header .= $content."\r\n\r\n";

  • Please, if anybody can help me.... my mail is rotcivchen@hotmail.com

    thanks a lot

  • hi, thanks a lot for the code. It work great..!!! but i have just one problem. The attachment arrives to my mailbox like text. Just text... if a send a PDF file, i got a TEXT like this "JVBERi0xLjMNJf////8NMSAwIG9ia­g08PA0vVGl0bGUgKP7/AGQAbwBjAHU­AbQBlAG4AdCkNL1Byb2R1Y2VyIChBb­Xl1bmkgUERGIENvbnZlcn".

  • Hi,

    Great video. Having trouble with the code, the attachments are not being decode, and show as 0kb in the email. Sure it's something simple. Could I send you my code, or could you supply a working copy.

    Thanks

    Ed

  • @erf05 double and tripple check that all your case and spelling is right.

    then, if it still doesn't work. PM me.

  • Could someone provide me with this txt or the php file? my email is Maria2k6@gmail.com

    Thanks,

    Maria

  • Hi,

    I am getting a syntax error on this particular code:

    $content = chunk_split(base64_encode(file­_get_contents($file)));

    I really dont know why....Could you please help me out.

    Because the error which I get is Syntax Error: Unexpected T_Variable

  • @pitambar

    check this good code lines:

    //we receive the temporal name of the file

    $temp_name = $_FILES['attachment']['tmp_nam­e'];

    $file = $temp_name;

    $content = chunk_split(base64_encode(file­_get_contents($file)));

  • Thanks for this very useful video tutorial! It's explained in a very simple way so all my compliments to that!

  • Now, I had a little bit a problems with some parts of the code because I tried to accommodate some part of it to suite my needs and to see how it works.

    I noticed 2 things:

    - If I use (') - as a quotation marks inside of (") it will nor work. It only works with (\"). Usually in PHP when I work with HTML it does not matter.

    - In some parts of the code it is OBLIGATORY to put double new lines/paragraphs like this: "\r\n\r\n". Otherwise it will not work again.

  • @kristijanmne I though that it should be useful also to put this to on comments even if I only can guess why is it happening.

    Another thing that I wanted to ask is this:

    "Content-Transfer-Encoding: 7bit" - it is ok to put it for "Content-type: text/html" and is there any thing that I or others should know about this when I send mails in "charset=utf-8"?

    Beside this, it works like a charm for me!

    Greetings from Montenegro (EU)! :)

  • Comment removed

  • Thank you for this clear example.

    I did exactly as you done, but am getting an empty file (0 kb size). I saw also your second video with the error example, i checked every letter in my file but find nothing.

    Am getting this error:

    Warning: file_get_contents() [function.file-get-contents]: Filename cannot be empty in /home/.................. /sendfile.php on line 30

    success

    Thank you

    Yosef

  • @lingachannel Your filename is not. Send me a pm with your code

  • @optikalefxx

    Thank you for your quick replay

    Look to the txt file please: (url)

    tranem.linga.org/Temp/sendmail­.txt

    Thanks a lot

    Yosef

  • @optikalefxx I found the problem

    my mistake was here:

    $temp_name = $_FILES['attachment']['temp_na­me'];

    it should be:

    $temp_name = $_FILES['attachment']['tmp_nam­e'];

    Thank you

  • Comment removed

  • Comment removed

  • Comment removed

  • How should I modify the code when I want to be able to send the email either with attachment or without. Because when I try without it obviously writes me No attachement.

  • @qwertzpoi SOLVED

  • @qwertzpoi you need to first get rid of the 'if else' check for the file being posted. The !emtpy($_FILES['attachment']['­name'] bit

    and then you need to kill the attachment "part" basically the code underneath of the comment // file attachment. Cuz with no attachment you don't want to send those headers.

  • Really good video it was exactly what I was looking for but I got parse error on this line

    $header .= "Content-Disposition: attachment; filename=\"",.$file_name."\"\r­\n\r\n";

    can you please look at it? thanks

  • @qwertzpoi You've got a random comma it looks like

  • @optikalefxx  Thanks I am stupid, I wondered what the parse error could be. I suspected the quotes. Anyway thanks for the awesome piece of code.

  • Comment removed

  • Thanks a lot! you are the man!

    What if i needed to send more than two attachments? how would i change the code?

  • Thanks a lot! you are the man!

    What if i needed to send more than two attachments? how would i change the code?

  • Thanks a lot! After wathcing your movie and lots of swearing, I finally made it and actually started to understand what I was doing.

    Tip for attachments: I found out that my Ubuntu Server limited my file attachment size to 2 MB. You have to edit the php.ini file and edit the line "upload_max_filesize =2MB"

  • @stonheneg79 good point, i hope everyone reads this and notes that they might need to make this change.

  • am having trouble with this code.... the attachment is not showing what type of file it is...

  • @007chiranth Make sure you spelled your content types correctly

  • Excellent video!!!

  • Comment removed

  • Comment removed

  • How can I get copy of this code in text format

  • @mrgarrett2000 as soon as square bracket.com is ready all the sources will be up

  • @optikalefxx ETA? (from a weekly watcher)

  • @ransombot ask my designer lol. After this tuesday serious development begins. Say 1 month before you see something up there.

  • Comment removed

  • Man, thats was amazing. I need some help to finally make my php work. Would you be willing to have a look at it and then we can talk about how much you would charge?

  • @raphagcwill sure thing, send me a PM.

  • I am getting a corrupt attachment. Any ideas?

  • @snacktreat Did you watch the trouble shooting video? If so you cam send me your code and I'll see what's up

  • So to you guys that are having issues check the following:

    - You are not using windows, seriously

    - its $_POST not $POST

    - text/plain not txt/plain

    - Make sure you punctuation matches mine

    - PHP variables start with a $

  • What am I doing wrong? I cannot get this script to work for me. I have entered the necessary info into the spaces provided yet I cannot get the form to work. Any suggestions?

  • @Sassci send me your code

  • There is a easy way to get the extension:

    $filename = "test.doc";

    $ext = end(explode(".",$filename));

    echo $ext; // doc

  • Brilliant!

  • What I mean is, instead of just getting the last 4 you could do something like this:

    $dot_index = stripos($base, ".");

    $extension = substr($base, $dot_index);

    That will return the extension and then you can just compare it to all the elements in the allowed extension array and not have to worry about hard-coding the extension length.

  • @warlord90210 i thought about that. But you would need to get the LAST index of "." because we can't gurantee there is only 1 dot. so i figured it was safer to get the end, because we can gurantee the end is the extension

  • Very true very true, I thought about that myself after I posted the comment.

    Oh well, either way is good I suppose, great tutorial as always.

  • Great video, could you instead check for the length of the array for the different types allowed and then you wouldn't have to keep a constant 4 for the length?

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more