Subject: | Inline (embedded) Images |
Date: | Thu, 30 Apr 2015 20:41:52 -0400 |
To: | bug-Email-Send-SMTP-Gmail [...] rt.cpan.org |
From: | "Devin Ceartas" <devin [...] nacredata.com> |
Perl 5.20.2
Email::Send::SMTP::Gmail 0.96
I found the following diff useful in sending embedded images, e.g. using
the HTML such as:
<body><img src="cid:logo.png"><br>Test with Image</body>
devin
--
contact info: http://nacredata.com/devin
--- Gmail.orig Thu Apr 30 20:14:56 2015
+++ Gmail.pm Thu Apr 30 20:35:42 2015
@@ -285,7 +285,13 @@
{
print "With Attachments\n" if $verbose;
$self->{sender}->datasend("MIME-Version: 1.0\n");
- $self->{sender}->datasend("Content-Type: multipart/mixed;
BOUNDARY=\"$boundary\"\n");
+ if ('inline' eq lc($properties{'-disposition'})) {
+ $self->{sender}->datasend("Content-Type: multipart/related;
BOUNDARY=\"$boundary\"\n");
+ }
+ else {
+ $self->{sender}->datasend("Content-Type: multipart/mixed;
BOUNDARY=\"$boundary\"\n");
+ }
+
# Send text body
$self->{sender}->datasend("\n--$boundary\n");
@@ -312,7 +318,13 @@
$self->{sender}->datasend("--$boundary\n");
$self->{sender}->datasend("Content-Type: $contentType;
name=\"$fileName\"\n");
$self->{sender}->datasend("Content-Transfer-Encoding:
base64\n");
- $self->{sender}->datasend("Content-Disposition: attachment;
=filename=\"$fileName\"\n\n");
+ if ('inline' eq lc($properties{'-disposition'})) {
+ $self->{sender}->datasend("Content-ID: <$fileName>\n");
+ $self->{sender}->datasend("Content-Disposition: inline;
=filename=\"$fileName\"\n\n");
+ }
+ else {
+ $self->{sender}->datasend("Content-Disposition:
attachment; =filename=\"$fileName\"\n\n");
+ }
# Google requires us to divide the attachment
# First read -> Encode -> Send in chunks of 76
@@ -361,7 +373,13 @@
$self->{sender}->datasend("--$boundary\n");
$self->{sender}->datasend("Content-Type: $contentType;
name=\"$fileName\"\n");
$self->{sender}->datasend("Content-Transfer-Encoding:
base64\n");
- $self->{sender}->datasend("Content-Disposition: attachment;
=filename=\"$fileName\"\n\n");
+ if ('inline' eq lc($properties{'-disposition'})) {
+ $self->{sender}->datasend("Content-ID: <$fileName>\n");
+ $self->{sender}->datasend("Content-Disposition: inline;
=filename=\"$fileName\"\n\n");
+ }
+ else {
+ $self->{sender}->datasend("Content-Disposition:
attachment; =filename=\"$fileName\"\n\n");
+ }
# Google requires us to divide the attachment
# First read -> Encode -> Send in chunks of 76