#!/usr/bin/perl use v5.030; # strictness implied use warnings; use Email::Simple::Markdown; use Email::Sender::Simple qw(sendmail); use Email::Sender::Transport::SMTP qw(); use Try::Tiny; use Config::Tiny; my $ini_path = qw( /home/wilma/7.values.ini ); my $sub_hash = "my_smtp"; my $Config = Config::Tiny->new; $Config = Config::Tiny->read( $ini_path, 'utf8' ); # -> is optional between brackets my $host = $Config->{$sub_hash}{'host'}; my $port = $Config->{$sub_hash}{'port'}; my $username = $Config->{$sub_hash}{'sasl_username'}; my $pass = $Config->{$sub_hash}{'sasl_password'}; my $ssl = $Config->{$sub_hash}{'ssl'}; say "values are $host $port $username $ssl"; my $output = "Come here, Mr. Watson"; my $message = Email::Simple::Markdown->create( header => [ Subject => "Report", To => 'tallharry84@gmail.com', From => 'noreply@foo.com' ], body => $output ); try { sendmail( $message, { from => 'noreply@foo.com', transport => Email::Sender::Transport::SMTP->new( { host => $host, port => $port, sasl_username => $username, sasl_password => $pass, ssl => $ssl, } ) } ); } catch { warn "sending failed: $_"; }; __END__ wilma@fourth:~$