Page 1 of 1
embedding attachments strings
Posted: Sat Dec 27, 2008 5:39 pm
by Lionel
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.
Re: embedding attachments strings
Posted: Tue Dec 30, 2008 10:03 am
by student101
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;
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>
Cheers
If for some reason(that I have not found) there is a way, then someone will post it.
Re: embedding attachments strings
Posted: Tue Dec 30, 2008 10:59 am
by Lionel
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
Re: embedding attachments strings
Posted: Tue Dec 30, 2008 11:35 am
by student101
Lionel wrote:Only draw back for me is I can embed anything but images from database
I don't get what you are saying? You can but you can't?
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!
If you find it - please post it!
Cheers
Re: embedding attachments strings
Posted: Fri Jan 02, 2009 11:31 pm
by Chris Corbyn
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'
));
Re: embedding attachments strings
Posted: Sat Jan 03, 2009 12:22 am
by student101
It can't be that simple?
I have attempted similar but your method makes more sense.
Thank you.
Cheers
Re: embedding attachments strings
Posted: Sat Jan 03, 2009 1:50 am
by Chris Corbyn
I'll be sure to make it more complicated in a future release
<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'
);
And for files on disk it looks like this:
Code: Select all
$message->setBody(
'<img src="' .
$message->embed(Swift_Image::fromPath('filename.gif'))
. '" />',
'text/html'
);
There's a bit less class-clutter coming in v4 (beta coming out any time now).
</side-note>