-1

this question is related to HTML image not showing in Gmail , but the answers there do not (or no longer) work.

the problem is that my perl program (below) fails when my html-formatted messages that I want to send off as soon as an img tag is included. it does not matter whether the image itself is served from the google drive or not. I am guessing that I am running into a novel gmail restriction (my script used to work), but I am not sure.

(of course, this problem is not that my recipients do not see the image; it is that the sending perl script aborts with an error---unfortunately, not with more information explaining to me why it is an error. of course, I understand that my recipients need to agree to view images to prevent tracking.)

so here are my questions:

  1. is this a gmail or a perl module problem?

  2. is it possible to send images, so that if my recipients want to see images from my website (preferably not just images from my google drive as in my example below), they can agree to see this?

  3. is it possible to get a better error message from google about why it fails?

here is the [almost] working code:

#!/usr/bin/perl -w
use strict;
use warnings;

use Email::MIME::CreateHTML;
use Email::Send;
use Email::Send::Gmail;

my $toemail = 'ivo.welch@gmail.com';
my $subject = 'testing image mailing';
my $bodytext= '<html> <body> fails: <img src="https://drive.google.com/open?id=1K4psrWWolTSqx_f6MQP-T1-FMFpegT1Trg" alt="photo" />  </body> </html>\n';

use readcredentials;
my $gmailaccount= readcredentials( 'account' );
my $gmailuserlogin= readcredentials( 'userlogin');
my $gmailpasswd= readcredentials( 'gmailpassword');

eval {
  my $message = Email::MIME->create_html(
                                         header => [
                                                    From   => $gmailaccount,
                                                    To      => $toemail,
                                                    Subject => $subject,
                                                   ],
                                         body => $bodytext,
                                        );

  my $sender = Email::Send->new(
                                {   mailer      => 'Gmail',
                                    mailer_args => [
                                                    username => $gmailuserlogin,
                                                    password => $gmailpasswd,
                                                   ]
                                }
                               );

  $sender->send($message);
};
warn "Error sending email: $@" if $@;

print STDERR "emailed!\n";
Community
  • 1
  • 1
ivo Welch
  • 2,427
  • 2
  • 23
  • 31
  • 5
    "this problem is not that my recipients do not see the image; it is that the sending perl script aborts with an error" What is the exact error message? – ThisSuitIsBlackNot Dec 14 '16 at 22:19
  • no error. stranger yet---after updating all cpan modules, the error has gone away. so I need to apologize for this. I don't understand why, but I cannot replicate it any longer---and before, I had replicated it dozens of times. – ivo Welch Dec 15 '16 at 05:41

1 Answers1

2

I ran your script, with some modifications to remove the dependency on readcredentials to make it run in my environment, and the email was delivered with no problem. Problems could be:

  1. You could have some problems with your gmail credentials.
  2. The script downloads and attaches the image, so perhaps your local environment is preventing the image from being downloaded.

But without your specific error message, it's hard to diagnose any further.

Adam Millerchip
  • 20,844
  • 5
  • 51
  • 74
  • no error. stranger yet---after updating all cpan modules, the error has gone away. so I need to apologize for this. I don't understand why, but I cannot replicate it any longer---and before, I had replicated it dozens of times. – ivo Welch Dec 15 '16 at 05:41