Welcome to WebmasterWorld Guest from 54.172.221.7

Forum Moderators: phranque

Sendmail: linking to an image

     
3:00 am on Dec 5, 2018 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month

joined:Mar 15, 2013
posts: 997
votes: 95


I don't use sendmail a lot, and I can't quite remember how to make this work right. I'm trying to send an email to an admin when a user submits a form, and I want to link to an image if they submitted one.

But in Outlook, the link is removing the first 2 characters of the link. So when I send:

<img src="https://www.example.com/image.jpg">

Outlook is getting:

<img src=ttps://www.example.com/image.jpg">

But it works fine in Thunderbird.

I'm coding in Perl, but I put it here because I think it's really a sendmail question:

 # set $mailprog, $username, $subject, and $boundary
$img = "<img src='https://www.example.com/$pic'>";

open(MAIL,"|$mailprog -t");
print MAIL <<EOF;
To: admin\@example.com
From: $username
Subject: $subject
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="$boundary"

This is a multi-part message in MIME format.

--$boundary
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

(blah blah blah)

--$boundary
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">

<font face=Arial>
(blah blah blah)

$img
</font>

--$boundary--

EOF
close MAIL;


I have the same problem if I change the <img src...> tag to <a href...>. The problem is always following the =.

What's the correct way to code this?
4:14 am on Dec 5, 2018 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:11522
votes: 177


perhaps outlook is trying to remove images and it gets munged in the process.

you might try embedding a base64 encoded image in the body of the email and modify the src to appropriately refer to that image.
4:17 am on Dec 5, 2018 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:11522
votes: 177


this is merely a shot in the dark, but try using the qq quoting operator and double quotes for the attribute value to see if that fixes anything:
$img = qq(<img src="https://www.example.com/$pic">);
9:06 pm on Dec 5, 2018 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month

joined:Mar 15, 2013
posts: 997
votes: 95


Well, it looks like the problem is any link, not just an image link :-( The <a href...> link is messing up, too. So this:

<a href="https://www.example.com/view.php?id=csdude">https://www.example.com/view.php?id=csdude</a>

becomes:

<a href=ttps://www.example.com/view.php?id=dude">https://www.example.com/view.php?id=dude</a>

(removing the next 2 digits after both equal signs)

The code I'm using here, based on your suggestion with qq():

use URI::Escape;

$uri_user = uri_escape($username);
$link = qq($home/view.php?id=$uri_user);
11:04 pm on Dec 5, 2018 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15374
votes: 725


Just for ### and giggles: What happens if you sneak in a couple of extra spaces--or, I guess, a couple of non-space characters--between the = sign and the "http ? (And, I guess, slip in two bogus leading characters at the front of each parameter value.)

Something is niggling at the edge of my mind and I'm trying to lure it in closer.
11:15 pm on Dec 5, 2018 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:11522
votes: 177


Well, it looks like the problem is any link, not just an image link :-( The <a href...> link is messing up,

indeed i forgot you had mentioned that.
1:28 am on Dec 6, 2018 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month

joined:Mar 15, 2013
posts: 997
votes: 95


Just for ### and giggles: What happens if you sneak in a couple of extra spaces--or, I guess, a couple of non-space characters--between the = sign and the "http ? (And, I guess, slip in two bogus leading characters at the front of each parameter value.)

Well, then it would break on my Thunderbird! LOL And it currently seems to work fine on both iPhone and Android's email, so I guess that adding characters would make it break on those, too.

This seems to only be a problem for Outlook, but I can't find any reference to it anywhere else. The admin is specifically using Outlook 2007, if that helps?
1:37 am on Dec 6, 2018 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month

joined:Mar 15, 2013
posts: 997
votes: 95


Wait, I think I found it! The problem is here:

Content-Transfer-Encoding: quoted-printable


QP works by using the equals sign = as an escape character... an ASCII equal sign (decimal value 61) must be represented by =3D


[en.wikipedia.org...]

So it looks like changing all of the = to =3D should work (in theory, I haven't tested it). What's the preferred Content-Transfer-Encoding for email, though, if not "quoted-printable"?
2:37 am on Dec 6, 2018 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:11522
votes: 177


i thought it might be related to encoding - still don't understand why it would try to decode something that wasn't hexadecimal digits.