Created
December 21, 2013 07:17
-
-
Save azumakuniyuki/8066415 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env perl | |
use strict; | |
use warnings; | |
use utf8; | |
use Encode; | |
use Acme::Nyaa; | |
use Email::MIME; | |
use Email::MIME::Creator; | |
use Net::SMTPS; | |
use Authen::SASL; | |
my $from = '"キジトラ" <kijitora@example.com>'; | |
my $rcpt = '"三毛猫" <mikeneko@azumakuniyuki.org>'; | |
my $subj = '年末のご挨拶'; | |
my $mesg = << 'EOM'; | |
いつもお世話になっております、株式会社キジトラのあずまです。 | |
本年も大変お世話になり誠に有り難う御座いました。来年も引き続きご愛顧賜りますよう | |
従業員一同お願い申し上げます。 | |
EOM | |
my $nyaa = Acme::Nyaa->new; | |
my $mime = Email::MIME->create( | |
'header' => [ | |
'From' => encode( 'MIME-Header-ISO_2022_JP', $from ), | |
'To' => encode( 'MIME-Header-ISO_2022_JP', $rcpt ), | |
'Subject' => encode( 'MIME-Header-ISO_2022_JP', $subj ), | |
], | |
'attributes' => { | |
'content_type' => 'text/plain', | |
'charset' => 'UTF-8', | |
'encoding' => '8bit', | |
}, | |
'body' => $nyaa->cat( \$mesg ), | |
); | |
my $args = { | |
'Port' => 587, | |
'doSSL'=> 'starttls', | |
'SSL_verify_mode' => 'SSL_VERIFY_NONE', | |
}; | |
my $user = 'azumakuniyuki@gmail.com'; | |
my $pass = 'd@nc1ng9u33n'; | |
my $smtp = Net::SMTPS->new( 'smtp.gmail.com', %$args ); | |
my $sasl = Authen::SASL->new( | |
'mechanisms' => 'Digest-MD5', | |
'callback' => { 'user' => $user, 'pass' => $pass, 'authname' => $user } | |
); | |
$smtp->auth( $sasl ); | |
$smtp->mail( [ split( ' ', $from ) ]->[1] ); | |
$smtp->to( [ split( ' ', $rcpt ) ]->[1] ); | |
$smtp->data; | |
$smtp->datasend( $mime->as_string ); | |
$smtp->dataend; | |
$smtp->quit; | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment