#!/usr/bin/perl use utf8; use strict; use warnings; use feature qw! say !; use Encode; use MIME::Entity; use Net::SMTP::SSL; # SMTPサーバの設定 my %smtp = ( Server => "smtp.gmail.com", Port => "465", User => 'user@remora.cx', Password => "パスワード", ); # メールヘッダの設定 my %mail = ( From => '送信元 ', To => '宛先 ', Subject => "テスト件名", ); # ヘッダをB符号化 $_ = encode( "MIME-Header-ISO_2022_JP", $_ ) for values %mail; # 文字コードを指定 $mail{Type} = "text/plain; charset=utf-8"; # Base64符号化 $mail{Encoding} = "base64"; # メールの本文 $mail{Data} = <build( %mail ); say $mime->stringify; # メールを送信 my $s = Net::SMTP::SSL->new( $smtp{Server}, Port => $smtp{Port} ); $s->auth( $smtp{User}, $smtp{Password} ); $s->mail( $mail{From} ); $s->to( $mail{To} ); $s->data; $s->datasend( $mime->stringify ); $s->dataend; $s->quit;