I've got mailings that need to be sended using cron. When I load the script manualy all works fine. With cron i get broken images.
to change the src of my img i used:
$body = eregi_replace("managersrc_logo","images/managers/acertainlogo.jpg",$body);
Because i thaught that it is importent to use absolute paths i also tried:
$body = eregi_replace("managersrc_logo","http://www.site.com/images/managers/acertainlogo.jpg",$body);
In that case i even do not see the images when i run the cronscript manualy. Nor the automated cron will display me the images.
When i check the source of the mail that is received i always see "cid:encryptedstuff" even if i use absolute paths? Why is that? I just want my absolute paths being printed in the src attribute of the img tag. Who changes my absolute path to cid: ? is it php, phpmailer or outlook itself?
Any help someone?
can you post a sample html before and after being replaced (but before being sent)? maybe it has additional characters that break the url, ie src="/managersrc_logo". Also, maybe your mailing program has an option to integrate the images inside the message and can't find them?
The problem was an older version of phpmailer. I updated to the new version and the images are displayed perfectly now!!
Related
If I'm not being clear about anything let me know... I'm new to SO.
I'm having troubles getting Gmail to approve of my image URL that will activate my PHP script to track when people open my emails.
Gmail only allows me to "insert" photos that are specifically image files, such as png or jpg files. I have tried using a file-include mechanism:
http://www.example.com/?file=image.png with a two-line PHP script that includes the png file and then writes to a log all the tracking info. However, I have found this doesn't work since I'm technically referencing index.php in the URL.
I have also tried http://www.example.com/script.php where script.php would look like this:
<img src=image.png>
<?php
// write "Someone viewed your mail" in logs
?>
This doesn't work either because I'm still referencing a PHP file.
I'm using the Insert Photo > Web Address feature in Gmail... should I be inserting the file differently to fix my problem? I need to find a way to directly reference an image file on my server but also activate the PHP script.
Any ideas? Am I overlooking something obvious?
Figured out I can do this with Thunderbird:
Write --> Insert --> HTML
In the HTML box:
<img src="www.mysite.com/script.php">
Hopes this helps anyone who had my problem
I am sending email using PHPmailer and tying to embed image in mail body (using CID method <img src="cid:qrcode" />) but it always attaching image instead of embedding.Can anyone tell me what's wrong with my code (commented lines in code, already tried. ).
Here is the screenshot of my code
First of all you're using a very old version of PHPMailer, and have based your code on a very old example. Get the latest.
The other obvious problem is that while you're putting HTML into Body, you've commented out the call to isHTML(), so your message is being sent as plain text, which has no concept of displaying images inline. Uncomment this line:
$mail->isHTML();
Also bear in mind that in MIME there is essentially no difference between attachments and inline images - everything is an attachment, it's just that some attachments may be referred to from HTML parts, and HTML-capable clients can make use of that linkage.
If Outlook is removing src attributes, that's clearly not your sending code's problem. Outlook does some very unpleasant things to email.
One other minor thing: instead of dirname(__FILE__) you can use __DIR__ in any current version of PHP.
just as an assistance I encountered the same problem and after much mumbling arrived at a solution which might help others.
Tried dumping the image in the same folder - nope
Tried DIR variable to dynamicalyly pull in the image - nope
Finally, hardcoded the path to the folder in which my embedded image lived, hurrah
Magic forumla for me (using PHPmailer v5.5) - note I'm using Plesk so your definitive path may differ, use mine as a guide...
$mail->AddEmbeddedImage("/var/www/vhosts/{domainname}/httpdocs/{foldername)/image.jpg", "emailimg", "image.jpg");
I note that when calling in the image as an embedded image that i had to use the same filename as I think PHPmailer uses the structure:
embedded-img-name source, reference id, embedded-img-name within the internal AddEmbeddedImage call
Hope it helps someone!
Try this code i think it will work for you
$mail->AddEmbeddedImage('img/2u_cs_mini.jpg', 'logo_2u');
and on the tag put src='cid:logo_2u'
Recently I have moved from my staging server to production server and I don't have access to any of these servers.
Both of these servers are linux.
On the new server while generating the pdf using mPDF with symfony 1.4 framework, images like rupee symbol are not getting displayed instead a small red "x" symbol is getting displayed in pdf.
Also, when I try to give background image to pdf, full image path like "http://example.com/image/rupee-image.jpg" is getting displayed instead of image.
Rupee symbol, other images and background images are working fine on my staging server.
When, I did $mpdf->showImageError(), It's saying "mPDF Image Error: Could not find image file" and pasting the url in browser displays the image perfectly.
Any help will be greatly appreciated.
mPDF is telling you that it's not finding the image.
Without seeing your code it's difficult to hint you on what's wrong.
Still you probably what to try referring to your images using a full path locally.
So instead of reference like http://example.com/image/rupee-image.jpg
use something like /var/www/mysite/image/rupee-image.jpg , same as if checking the image is there using the command line.
HTH
I had similar problem, i fixed it with replacing http:// to https://. Watch out for it.
I fixed it myself... I have created a variable in my template and then replaced that variable with image location from my action class, using $mpdf->WriteHTML(str_replace('rupee_symbol','₹',$html1));
My problem was PHP 7 in this case! I check condition
if (!empty('/images/someimg.png')) {
echo '<img ...';
} else {
echo 'error in PHP 7';
}
Be carefull using it. Version PHP 7.0.19
I'm currently trying out the TinyButStrong library with openTBS plugin to edit an OpenOffice writer template.
If I correctly understand, you can change a default picture to something else using this:
[b.number;ope=changepic;from='pic_[val].png';default=current;adjust]
I tried changing the from='pic_[val].png' to from='example.jpg', this didn't change the picture however.
Anyone knows how to get this working? Help will be greatly appreciated.
Put a fixed value in parameter "from" should force the image (it worked for me).
If your field has been merged (that is it does not appear in the result file) and you have no error message, then having the image unchanged means that the target file cannot be found.
I think the 'example.jpg' file should be placed in the folder with the script that manages TBS and OpenTBS. Otherwise, you have to specify a path.
You don't actually need to the 'from' parameter to just switch a picture out. OpenTBS gets the path of the picture from the first parameter - in your case b.number (which hopefully contains a path to an image). Adjust is also not required, unless you are resizing the picture.
[b.number;ope=changepic;default=current;]
Assuming:
$b->number = '/path/to/image.png'
Also keep in mind, if b.number is a block, you may need to define your block boundary for the data to populate. (If you are able to see the path in the $TBS->PlugIn(OPENTBS_DEBUG_XML_SHOW) mode don't worry about this) Try using [b.number] if you are not sure your data is being processed.
I'm trying to test the PHPmailer class to embed image (http://www.google.gr/intl/en_com/images/srpr/logo1w.png) inside an e-mail
I'm using this code (along with standard one, that 100% works, mail is delivered):
$mail->AddEmbeddedImage($src, 'test', basename($src));
and this is placed the e-mail body:
<img src="cid:test">
Image is not showing up. What may I doing wrong?
Taken from some piece of the documentation:
$path is the path of the filename. It can be a relative one (from your
script, not the PHPMailer class) or a full path to the file you want
to attach.
Have you tried using a local image?
cid:test isn't valid url for image.