Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14
  1. #1
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,800
    Member #
    5580
    Liked
    726 times
    If you have a Kindle 3 and use it around WiFi (in your house or wherever), you can create your
    own .mobi files and send them free to your Kindle using the free email account that Amazon gives you.

    First, I found this PHP Class for creating .mobi files:
    https://github.com/raiju/phpMobi
    The author indicates that the class is experimental, but it does work really good.
    You can create the .mobi from a file, or from HTML (on the fly):

    Then, I found this PHP script for emailing .mobi files to your "@free.kindle.com" email address.
    You need to know your "free.kindle.com" email address, and you also need to give permission
    to receive emails from your website. This is done on your Amazon Kindle Management Section.

    PHP Code:
    <?php
    // Send a .mobi file to your Kindle.

    $my_file "My_Kindle_Book.mobi";
    $my_path $_SERVER['DOCUMENT_ROOT']."/kindlestuff/";
    $my_name "John Smith";
    $my_mail "info@mysite.com";
    $my_replyto "info@mysite.com";
    $my_subject "Here is my Kindle Book";
    $my_message "Kindle Book";
    $kindle_email"myemailaccount@free.kindle.com";

    $message mail_attachment($my_file$my_path$kindle_email$my_mail$my_name$my_replyto$my_subject$my_message);

    function 
    mail_attachment($filename$path$mailto$from_mail$from_name$replyto$subject$message) {
        
    $file $path.$filename;
        
    $file_size filesize($file);
        
    $handle fopen($file"r");
        
    $content fread($handle$file_size);
        
    fclose($handle);
        
    $content chunk_split(base64_encode($content));
        
    $uid md5(uniqid(time()));
        
    $name basename($file);
        
    $header "From: ".$from_name." <".$from_mail.">\r\n";
        
    $header .= "Reply-To: ".$replyto."\r\n";
        
    $header .= "MIME-Version: 1.0\r\n";
        
    $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
        
    $header .= "This is a multi-part message in MIME format.\r\n";
        
    $header .= "--".$uid."\r\n";
        
    $header .= "Content-type:text/plain; charset=iso-8859-1\r\n";
        
    $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
        
    $header .= $message."\r\n\r\n";
        
    $header .= "--".$uid."\r\n";
        
    $header .= "Content-Type: application/octet-stream; name=\"".$filename."\"\r\n"// use different content types here
        
    $header .= "Content-Transfer-Encoding: base64\r\n";
        
    $header .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n";
        
    $header .= $content."\r\n\r\n";
        
    $header .= "--".$uid."--";
        if (
    mail($mailto$subject""$header)) {
            
    $message"Your Kindle Book has been sent!"// or use booleans here
        
    } else {
            
    $message"Your Kindle Book did not send for some reason.";
        }
    return 
    $message;
    }

    ?>
    Finally ...
    I put them together into this cool script for copying and pasting text (no images) into a textarea,
    click a button, and it shows up on your Kindle! ... just like any other eBook that you download.

    As you browse the internet and come across a good article or story, and you wish to read it
    later on, copy and paste it .. send it to your Kindle. Read it in bed later on tonight.
    Maybe you want to send some text or data from Word, Excel, Recipes, Phone numbers ...?

    See the attached .zip file

    Download the zipped file, upload (FTP) the files just how they are, with the same directory structure.
    You only need to edit the "index.php" script. Enter your information and things where they are described (comments are scattered within "index.php").

    Another idea for this ... collaborate with other Kindle users and
    send things back and forth between Kindles.

    Think outside the box and contribute any other ideas you have.
    Let's have some fun with Kindles and PHP!

    Enjoy!


  2.  

  3. #2
    Junior Member
    Join Date
    Sep 2012
    Posts
    7
    Member #
    32928
    This is really cool - and it does work Thank you. Is there any way this script can be joined with a simple form in which I ask for the Kindle email of my visitor, and send a specified mobi file to that address automatically?

  4. #3
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,800
    Member #
    5580
    Liked
    726 times
    Sure that can work, but the Kindle owner needs to give your domain
    permission to send them emails ... (example: @zoltan.com ) if your
    website was www.zoltan.com

    Not all Kindle owners are very technically-minded ... and may not know how
    to do that in their Amazon 'Manage My Kindle' section. That would be the
    only problem ... if they didn't set it up properly, they would not get the file
    sent to their Kindle.
    Webzarus likes this.


  5. #4
    Junior Member
    Join Date
    Sep 2012
    Posts
    7
    Member #
    32928
    Yes, I am aware of this risk, but would be willing to take it - I think if one informs the user/reader of this, it will be all right

    I've seen and used this feature on openlibrary and baen books (two completely different implementations, I believe), and am really fond of it, that is why I would like to implement it on our site. However, I am undereducated in php, to say the least. Can you point me at where and what I should change in your code to get a work around for this?

    So the idea is that on the front end, the user enters his/her Kindle email address, pushes a button, and lo, the file (which had been ftp-d to the server) is miraculously sent to the designated device.

    Any help much appreciated!

  6. #5
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,800
    Member #
    5580
    Liked
    726 times
    You need to tell me more about the "file which was ftp-d to the server".

    What kind of file?
    and what is the filetype?

    In my example, I'm emailing a string of text, not an actual file.
    In your script, a different part of the MOBI function would be used to email an actual file.

    I just don't know what you mean by "file".


  7. #6
    Junior Member
    Join Date
    Sep 2012
    Posts
    7
    Member #
    32928
    Quote Originally Posted by mlseim, post: 241448
    You need to tell me more about the "file which was ftp-d to the server".

    What kind of file?
    and what is the filetype?

    In my example, I'm emailing a string of text, not an actual file.
    In your script, a different part of the MOBI function would be used to email an actual file.

    I just don't know what you mean by "file".
    Oh, sorry (you see, this is how undereducated I am in these things...:P) - a mobi file it should be. So the procedure is as follows: I create the mobi ebooks, upload them to my site, into a designated folder. The visitor comes to the site, goes to the page of one of the ebooks, where he enters his/her Kindle email address in a form, pushes a button, and the mobi ebook of his/her choice arrives onto his/her Kindle.

    The script, therefore, should do the following: fetch the mobi file from the folder on the server, and send it to the email address the visitor enters into the form. So I guess, I do not really need the mobi functions that compiles an html source into a file, but rather the sending part that delivers the mobi to the Kindle.

  8. #7
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,800
    Member #
    5580
    Liked
    726 times
    My script uses a MOBI Class to create a MOBI file from HTML or Text (.txt).

    You already have a MOBI file, so you need a PHP script to simply attach
    the MOBI file (as a file attachment). When you do that and email it someone,
    that attached MOBI file is loaded to their Kindle.

    So my script isn't what you want ... but I'll look for an easy PHP "attach
    file to email script" and experiment with my own Kindle before I post it.

    ================================================== ===============

    I just experimented with attaching file to email using PHP.

    I can successfully attach at PDF, and it goes to my Kindle3.

    I have not found a way to attach a MOBI file. Apparently my webhost account
    doesn't have the MIME FileType for .mobi ? I tried PocketMobi and no luck:
    $fileatt_type = "application/x-mobipocket-ebook"; // File Type.

    So, if you can convert to PDF, or EPUB ... see if you can convert.

    Meanwhile, I'll try an EPUB book (.epub extension).

    Now realize that only Kindle 3 and higher can do the convert within Amazon.
    I don't know if attaching a file to email works with Kindle1 or Kindle2?


    ================================================== ====================

    Kindle won't support EPUB either, unless you use a native program to convert it to something else.

    Looks like PDF is pretty much the most universal between readers.
    Or convert files yourself to AZW and let PHP email those types.

    I suppose the real question might be ... what are your files? Real books, or some documents that you create?
    Are you only dealing with Kindle, or Nook and other ereaders?

    Maybe focusing only on Kindle is a bad idea?


  9. #8
    Junior Member
    Join Date
    Sep 2012
    Posts
    7
    Member #
    32928
    I have been experimenting, too, with a sendfile php script, and checked whether mobi can be sent to an ordinary email address - the script does not send any mobis, only gibberish at best (not as an attachment). I think I also seem to have some problem with the script, but one thing is assured: if I zip the mobi, and send it to a Kindle email, it does work. So, if the file is not mobi but a zipped mobi, it could do its job, too. However, my problem in all the sendfile scripts is this chunk of codes:

    PHP Code:
    $fp fopen($myfile,"r");
    $contents fread($fp,filesize($myfile));
    fclose($fp); 
    No matter what I do, it returns the error that it cannot calculate the size of that file, and 0 is not a valid attribute... Clueless. Thank you for your efforts at solving my lousy problem, anyway.

  10. #9
    Junior Member
    Join Date
    Sep 2012
    Posts
    7
    Member #
    32928
    Btw, one more thing: in your reply you said that "I'm emailing a string of text, not an actual file.", but as far as I can make out, you are actually calling the mobi file in the code, not the actual html the mobi class retrieves, aren't you:

    PHP Code:
    $my_file "My_Kindle_Book.mobi";
    $my_path $_SERVER['DOCUMENT_ROOT']."/kindlestuff/"
    and later on in defining the attachment. If I understand it correctly (which, then, might just not be the case...), your script can do what other scripts (stripped of the mobi class part) fail to.

  11. #10
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,800
    Member #
    5580
    Liked
    726 times
    For some reason it's not the same. The PHP MOBI Class I'm using creates a MOBI from
    HTML or .txt ... it must do something different such that it's not encoded the same?



Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search tags for this page

kindle email mailto
,

on kindle what to do with php file

,
php ebook kindle 3
,
php script kindle
,

send to kindle in php

Click on a term to search for related topics.
All times are GMT -6. The time now is 01:44 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2020 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com