Hello,
Is it possible to embed an image from database? I just started using this fabulous script, I am able to embed multiple images in my articles, but some of them are binaries from db.
Thank you.
embedding attachments strings
Moderators: Chris Corbyn, General Moderators
-
student101
- Forum Newbie
- Posts: 20
- Joined: Sun Sep 21, 2008 4:04 pm
Re: embedding attachments strings
This is not a possibility for Swftmail, why? I have attempted my ideas, searched and found nothing! not even basic help.
You can embed it via linking it;
Cheers
If for some reason(that I have not found) there is a way, then someone will post it.
You can embed it via linking it;
Code: Select all
<html>
<head>
<title>Page title</title>
</head>
<body>
<div id="Box">
<p>Image name</p>
<div style="height:120px; width:300px;><img src='http://www.example.com/images/imagename.jpg' alt="Alt text" /></div>
</div>
OR
<div style="height:120px; width:300px; background:url(http://www.example.com/images/imagename.jpg);"></div>
</body>
</html>If for some reason(that I have not found) there is a way, then someone will post it.
Re: embedding attachments strings
That was possible with phpmailer and a hack to embed image from database.
But I must say this Swift script is much more superior.
Only draw back for me is I can embed anything but images from database
But I must say this Swift script is much more superior.
Only draw back for me is I can embed anything but images from database
-
student101
- Forum Newbie
- Posts: 20
- Joined: Sun Sep 21, 2008 4:04 pm
Re: embedding attachments strings
I don't get what you are saying? You can but you can't?Lionel wrote:Only draw back for me is I can embed anything but images from database
If you want to send an "embedded" image via any mailer you need the image as a BLOB or the physical path to the image.
There is no possible method that I have found(with Swift or PHPMailer) to send someone an image other than through an attachment!
CheersIf you find it - please post it!
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: embedding attachments strings
Just skip the Swift_File class and pass the binary data directly.
Code: Select all
$message->attach(new Swift_Message_Part(
'<img src="' .
$message->attach(new Swift_Message_Image($binaryData, 'filename.gif', 'image/gif'))
. '" />',
'text/html'
));-
student101
- Forum Newbie
- Posts: 20
- Joined: Sun Sep 21, 2008 4:04 pm
Re: embedding attachments strings
It can't be that simple?
I have attempted similar but your method makes more sense.
Thank you.
Cheers
I have attempted similar but your method makes more sense.
Thank you.
Cheers
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: embedding attachments strings
I'll be sure to make it more complicated in a future release 
<side-note>
Actually, in v4 it looks something like this:
And for files on disk it looks like this:
There's a bit less class-clutter coming in v4 (beta coming out any time now).
</side-note>
<side-note>
Actually, in v4 it looks something like this:
Code: Select all
$message->setBody(
'<img src="' .
$message->embed(new Swift_Image($binaryData, 'filename.gif', 'image/gif'))
. '" />',
'text/html'
);Code: Select all
$message->setBody(
'<img src="' .
$message->embed(Swift_Image::fromPath('filename.gif'))
. '" />',
'text/html'
);</side-note>