Hi Timo,
Part of the issue was that my firewall did not like my smtp port,
so I chose another one.
And I got it working as soon as I understood the headers.
Email::MIME.create(
header => [ "Content-Transfer-Encoding" => "base64" ],
attributes => [ content-type => "application/zip; name=$imagename",
disposition => "attachment" ],
And "stringy":
$client.send( $from, @to, $email.as-string, :keep-going )
Thank you so much for sticking by me whist I fought through this.
I sincerely appreciate it.
-T
Here is my test code. If it looks a little worky, it
is because I cut it out of the actual code and I
had to add a bunch of the supporting subs:
<code>
#!/usr/bin/env perl6
use strict;
use Net::SMTP;
use Email::MIME;
use Terminal::ANSIColor; # color
my $Terminal = %*ENV<TERM>;
# print "\$Terminal = <$Terminal>\n";
( my $IAm =~ $?FILE ) ~~ s|.*"/"||;
my $ErrorCount = "0"; # 0 > is an error
my $Report;
sub PrintRed ( $Str ) {
if $Terminal ~~ /xterm || linux/ {
print color('bold'), color('red'), "$Str", color('reset');
}
}
sub AddToReport ( $Str ) { $Report ~= "$Str"; }
sub eMailReport () {
# Reference: https://github.com/retupmoca/P6-Net-SMTP
my $smtp = "redacted";
my $port = 80;
my $username = "redacted";
my $password = "redacted";
my $from = "$username";
my @to = qw [ p...@storall.biz tmew...@zoho.com ]; # This is
an array, not a string
my $Subject = "Subject: $IAm ERROR(s) = $ErrorCount";
my $imagename = "logout.zip";
my $imagepath = "/home/linuxutil";
my $image = "$imagepath/$imagename".IO.slurp(:bin);
my $email = Email::MIME.create(
header-str => [from => $from,
to => @to,
subject => $Subject ],
parts => [
Email::MIME.create(
header => [ content-transfer-encoding =>
"quoted-printable" ],
attributes => [ content-type => "text/plain", charset =>
"utf8" ],
body-str => $Report ),
Email::MIME.create(
header => [ "Content-Transfer-Encoding" => "base64" ],
# attributes => [ content-type => "image/x-portable-greymap",
attributes => [ content-type => "application/zip;
name=$imagename",
disposition => "attachment" ],
body => $image
)
]);
# say $email.as-string;
if ( not my $client = Net::SMTP.new(:server( $smtp ), :port( $port
), :debug( 0 ) ) ) {
$ErrorCount += 1;
PrintRed ( "SMTP: unable to open $smtp\n" );
AddToReport ( "SMTP: unable to open $smtp\n" );
return;
}
if ( not $client.auth( $username, $password ) ) {
$ErrorCount += 1;
PrintRed ( "SMTP: something is wrong with the username and/or
password\n\n" );
AddToReport ( "SMTP: something is wrong with the username and/or
password\n\n" );
return;
}
if ( not $client.send( $from, @to, $email.as-string, :keep-going ) )
{ PrintRed "SMTP Error: Failed to send\n\n"; }
$client.quit;
# Seez!!!
}
$Report = "If this works,\nI am going to be surprised";
eMailReport;
</code>