Skip to content

Instantly share code, notes, and snippets.

@Songmu
Created April 12, 2015 17:11
Show Gist options
  • Select an option

  • Save Songmu/2c2e1f306ccff6793341 to your computer and use it in GitHub Desktop.

Select an option

Save Songmu/2c2e1f306ccff6793341 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use 5.014;
use warnings;
use utf8;
my $ebook_convert = '/Applications/calibre.app/Contents/MacOS/ebook-convert';
my $file = shift;
if (!$file || ! -f $file) {
die "no files are specified!\n";
}
if ($file =~ /\.epub$/) {
my $orig_file = $file;
$file =~ s/\.epub$/\.mobi/;
my $r = system($ebook_convert, $orig_file, $file);
if ($r != 0) {
die "$!\n";
}
}
use Email::Send::SMTP::Gmail;
my ($mail, $error) = Email::Send::SMTP::Gmail->new(
-login => 'example@gmail.com',
-pass => 'xxxxxxxxxxxxxxxx',
-layer => 'ssl',
);
die "session error: $error" if $error;
$mail->send(
-to => 'example@kindle.com',
-attachments => $file,
);
$mail->bye;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment