#!/usr/bin/perl

use strict;
use warnings FATAL => 'all';
use Email::Simple;
use Email::Sender::Simple qw(sendmail);
use Email::Sender::Transport::SMTP::TLS;
use Getopt::Long;


my ( $dead_master_host, $new_master_host, $new_slave_hosts, $subject, $body );
GetOptions(
  'orig_master_host=s' => \$dead_master_host,
  'new_master_host=s'  => \$new_master_host,
  'new_slave_hosts=s'  => \$new_slave_hosts,
  'subject=s'          => \$subject,
  'body=s'             => \$body,
);

mailToContacts();
sub mailToContacts {
        my $transport = Email::Sender::Transport::SMTP::TLS->new(
                ctype => 'text/plain; charset=utf-8',
                encoding => 'utf-8',
                host     => 'smtp.163.com',
                port     => 25,
                username => '授权邮箱账号',
                password => '授权邮箱密码',
                );

        my $message = Email::Simple->create(
    header => [
        From           => 'xxx@163.com',
        To             => 'xxx@qq.com',
        Subject        => 'MHA',
        ],
        body           =>'MHA故障转移',
);
sendmail( $message, {transport => $transport} );
    return 1;
}
exit 0;
