PHPMailer adding images using the FOR loopStrange out of memory issue while loading an image to a Bitmap objectLazy load of images in ListViewHow do I auto-resize an image to fit a 'div' container?phpmailer column loop & skip NULLsHow to vertically align an image inside a div?Changing image size in Markdownphpmailer gmail emails go to spamdynamic content in Email using PHPmailerPHPMailer addStringEmbeddedImage and adding the same image more than oncePHPMailer - Send base64 image on email body
Holding rent money for my friend which amounts to over $10k?
Cuban Primes
Search string in file, replace it, and write back to file
When the match time is called, does the current turn end immediately?
Is Precocious Apprentice enough for Mystic Theurge?
Usage of the relative pronoun "dont"
A latin word for "area of interest"
Gimp perspective tool is not actually transforming
Failing students when it might cause them economic ruin
Pedaling at different gear ratios on flat terrain: what's the point?
How can I safely determine the output voltage and current of a transformer?
Divisor Rich and Poor Numbers
Why is so much ransomware breakable?
Have there been any examples of re-usable rockets in the past?
301 Redirects what does ([a-z]+)-(.*) and ([0-9]+)-(.*) mean
Would life always name the light from their sun "white"
Why is it correct to use ~た in this sentence, even though we're talking about next week?
Do high-wing aircraft represent more difficult engineering challenges than low-wing aircraft?
Find the area of the rectangle
Roman Numerals Equation 2
Is there a method to separate iron from mercury?
Why does Taylor’s series “work”?
How can we delete item permanently without storing in Recycle Bin?
Why didn't Daenerys' advisers suggest assassinating Cersei?
PHPMailer adding images using the FOR loop
Strange out of memory issue while loading an image to a Bitmap objectLazy load of images in ListViewHow do I auto-resize an image to fit a 'div' container?phpmailer column loop & skip NULLsHow to vertically align an image inside a div?Changing image size in Markdownphpmailer gmail emails go to spamdynamic content in Email using PHPmailerPHPMailer addStringEmbeddedImage and adding the same image more than oncePHPMailer - Send base64 image on email body
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have this PHP code:
for($x = 0; $x < count($obrazy); $x++)
$mail->AddEmbeddedImage($obrazy[$x], 'tel'.$x);
the variable "obrazy" is a table storing path (link to the image) e.g. "obraz/zdjecie.png". I need to do this with a loop because the array of obrazy can have a different size each time. The above loop does not work for me, because when I want to show this image in the mail, nothing is displayed.
$iterator = 0;
while ($row = mysqli_fetch_array($rezultat))
$mail->Body = $mail->Body.'//..........
<img src="cid:tel'.$iterator.'" style="
width: 160px;
display: block;
float: left;
"/> //..........
';
$iterator++;
"// ......" means another part of the code that does not matter to the question being asked. The while loop must be because I extract different data from the database. Everything works only the images do not want to be displayed in the email, even if instead of "$iterator" I enter the number. Links to the image contained in the table are RELIABLE for the PHP file.
php image email phpmailer
add a comment |
I have this PHP code:
for($x = 0; $x < count($obrazy); $x++)
$mail->AddEmbeddedImage($obrazy[$x], 'tel'.$x);
the variable "obrazy" is a table storing path (link to the image) e.g. "obraz/zdjecie.png". I need to do this with a loop because the array of obrazy can have a different size each time. The above loop does not work for me, because when I want to show this image in the mail, nothing is displayed.
$iterator = 0;
while ($row = mysqli_fetch_array($rezultat))
$mail->Body = $mail->Body.'//..........
<img src="cid:tel'.$iterator.'" style="
width: 160px;
display: block;
float: left;
"/> //..........
';
$iterator++;
"// ......" means another part of the code that does not matter to the question being asked. The while loop must be because I extract different data from the database. Everything works only the images do not want to be displayed in the email, even if instead of "$iterator" I enter the number. Links to the image contained in the table are RELIABLE for the PHP file.
php image email phpmailer
add a comment |
I have this PHP code:
for($x = 0; $x < count($obrazy); $x++)
$mail->AddEmbeddedImage($obrazy[$x], 'tel'.$x);
the variable "obrazy" is a table storing path (link to the image) e.g. "obraz/zdjecie.png". I need to do this with a loop because the array of obrazy can have a different size each time. The above loop does not work for me, because when I want to show this image in the mail, nothing is displayed.
$iterator = 0;
while ($row = mysqli_fetch_array($rezultat))
$mail->Body = $mail->Body.'//..........
<img src="cid:tel'.$iterator.'" style="
width: 160px;
display: block;
float: left;
"/> //..........
';
$iterator++;
"// ......" means another part of the code that does not matter to the question being asked. The while loop must be because I extract different data from the database. Everything works only the images do not want to be displayed in the email, even if instead of "$iterator" I enter the number. Links to the image contained in the table are RELIABLE for the PHP file.
php image email phpmailer
I have this PHP code:
for($x = 0; $x < count($obrazy); $x++)
$mail->AddEmbeddedImage($obrazy[$x], 'tel'.$x);
the variable "obrazy" is a table storing path (link to the image) e.g. "obraz/zdjecie.png". I need to do this with a loop because the array of obrazy can have a different size each time. The above loop does not work for me, because when I want to show this image in the mail, nothing is displayed.
$iterator = 0;
while ($row = mysqli_fetch_array($rezultat))
$mail->Body = $mail->Body.'//..........
<img src="cid:tel'.$iterator.'" style="
width: 160px;
display: block;
float: left;
"/> //..........
';
$iterator++;
"// ......" means another part of the code that does not matter to the question being asked. The while loop must be because I extract different data from the database. Everything works only the images do not want to be displayed in the email, even if instead of "$iterator" I enter the number. Links to the image contained in the table are RELIABLE for the PHP file.
php image email phpmailer
php image email phpmailer
asked Mar 23 at 16:18
MISIUMISIU
32
32
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Chances are your path or permissions are wrong; Check the return value from addEmbeddedImage
:
if (!$mail->AddEmbeddedImage($obrazy[$x], 'tel'.$x))
echo 'Failed to attach '. $obrazy[$x];
It's probably a good idea to turn the path into an absolute one, for example by saying something like __DIR__ . '/' . $obrazy[$x]
instead of just the relative path.
It may be that your current working directory is not where you think it is. Try doing it like this:
if (!$mail->AddEmbeddedImage(getcwd() . '/' . $obrazy[$x], 'tel'.$x))
echo 'Failed to attach '. getcwd() . '/' . $obrazy[$x];
Then it will show you the full path of the files it's failing to find, and you can check whether they are correct.
Failed to attach grafika/mate%2010%20pro.png
– MISIU
Mar 23 at 18:03
Return False ;(
– MISIU
Mar 23 at 18:03
Right, so check that the rest of the path is correct - for example try addingecho getcwd();
to see where it's currently running from - your path needs to be relative to that.
– Synchro
Mar 23 at 18:05
I'm working on xampp localhost so how do I use the absolute path?
– MISIU
Mar 23 at 18:06
It's the local file system path that's wrong, not a URL.
– Synchro
Mar 23 at 18:06
|
show 14 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55315809%2fphpmailer-adding-images-using-the-for-loop%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Chances are your path or permissions are wrong; Check the return value from addEmbeddedImage
:
if (!$mail->AddEmbeddedImage($obrazy[$x], 'tel'.$x))
echo 'Failed to attach '. $obrazy[$x];
It's probably a good idea to turn the path into an absolute one, for example by saying something like __DIR__ . '/' . $obrazy[$x]
instead of just the relative path.
It may be that your current working directory is not where you think it is. Try doing it like this:
if (!$mail->AddEmbeddedImage(getcwd() . '/' . $obrazy[$x], 'tel'.$x))
echo 'Failed to attach '. getcwd() . '/' . $obrazy[$x];
Then it will show you the full path of the files it's failing to find, and you can check whether they are correct.
Failed to attach grafika/mate%2010%20pro.png
– MISIU
Mar 23 at 18:03
Return False ;(
– MISIU
Mar 23 at 18:03
Right, so check that the rest of the path is correct - for example try addingecho getcwd();
to see where it's currently running from - your path needs to be relative to that.
– Synchro
Mar 23 at 18:05
I'm working on xampp localhost so how do I use the absolute path?
– MISIU
Mar 23 at 18:06
It's the local file system path that's wrong, not a URL.
– Synchro
Mar 23 at 18:06
|
show 14 more comments
Chances are your path or permissions are wrong; Check the return value from addEmbeddedImage
:
if (!$mail->AddEmbeddedImage($obrazy[$x], 'tel'.$x))
echo 'Failed to attach '. $obrazy[$x];
It's probably a good idea to turn the path into an absolute one, for example by saying something like __DIR__ . '/' . $obrazy[$x]
instead of just the relative path.
It may be that your current working directory is not where you think it is. Try doing it like this:
if (!$mail->AddEmbeddedImage(getcwd() . '/' . $obrazy[$x], 'tel'.$x))
echo 'Failed to attach '. getcwd() . '/' . $obrazy[$x];
Then it will show you the full path of the files it's failing to find, and you can check whether they are correct.
Failed to attach grafika/mate%2010%20pro.png
– MISIU
Mar 23 at 18:03
Return False ;(
– MISIU
Mar 23 at 18:03
Right, so check that the rest of the path is correct - for example try addingecho getcwd();
to see where it's currently running from - your path needs to be relative to that.
– Synchro
Mar 23 at 18:05
I'm working on xampp localhost so how do I use the absolute path?
– MISIU
Mar 23 at 18:06
It's the local file system path that's wrong, not a URL.
– Synchro
Mar 23 at 18:06
|
show 14 more comments
Chances are your path or permissions are wrong; Check the return value from addEmbeddedImage
:
if (!$mail->AddEmbeddedImage($obrazy[$x], 'tel'.$x))
echo 'Failed to attach '. $obrazy[$x];
It's probably a good idea to turn the path into an absolute one, for example by saying something like __DIR__ . '/' . $obrazy[$x]
instead of just the relative path.
It may be that your current working directory is not where you think it is. Try doing it like this:
if (!$mail->AddEmbeddedImage(getcwd() . '/' . $obrazy[$x], 'tel'.$x))
echo 'Failed to attach '. getcwd() . '/' . $obrazy[$x];
Then it will show you the full path of the files it's failing to find, and you can check whether they are correct.
Chances are your path or permissions are wrong; Check the return value from addEmbeddedImage
:
if (!$mail->AddEmbeddedImage($obrazy[$x], 'tel'.$x))
echo 'Failed to attach '. $obrazy[$x];
It's probably a good idea to turn the path into an absolute one, for example by saying something like __DIR__ . '/' . $obrazy[$x]
instead of just the relative path.
It may be that your current working directory is not where you think it is. Try doing it like this:
if (!$mail->AddEmbeddedImage(getcwd() . '/' . $obrazy[$x], 'tel'.$x))
echo 'Failed to attach '. getcwd() . '/' . $obrazy[$x];
Then it will show you the full path of the files it's failing to find, and you can check whether they are correct.
edited Mar 23 at 18:23
answered Mar 23 at 17:57
SynchroSynchro
19.6k95572
19.6k95572
Failed to attach grafika/mate%2010%20pro.png
– MISIU
Mar 23 at 18:03
Return False ;(
– MISIU
Mar 23 at 18:03
Right, so check that the rest of the path is correct - for example try addingecho getcwd();
to see where it's currently running from - your path needs to be relative to that.
– Synchro
Mar 23 at 18:05
I'm working on xampp localhost so how do I use the absolute path?
– MISIU
Mar 23 at 18:06
It's the local file system path that's wrong, not a URL.
– Synchro
Mar 23 at 18:06
|
show 14 more comments
Failed to attach grafika/mate%2010%20pro.png
– MISIU
Mar 23 at 18:03
Return False ;(
– MISIU
Mar 23 at 18:03
Right, so check that the rest of the path is correct - for example try addingecho getcwd();
to see where it's currently running from - your path needs to be relative to that.
– Synchro
Mar 23 at 18:05
I'm working on xampp localhost so how do I use the absolute path?
– MISIU
Mar 23 at 18:06
It's the local file system path that's wrong, not a URL.
– Synchro
Mar 23 at 18:06
Failed to attach grafika/mate%2010%20pro.png
– MISIU
Mar 23 at 18:03
Failed to attach grafika/mate%2010%20pro.png
– MISIU
Mar 23 at 18:03
Return False ;(
– MISIU
Mar 23 at 18:03
Return False ;(
– MISIU
Mar 23 at 18:03
Right, so check that the rest of the path is correct - for example try adding
echo getcwd();
to see where it's currently running from - your path needs to be relative to that.– Synchro
Mar 23 at 18:05
Right, so check that the rest of the path is correct - for example try adding
echo getcwd();
to see where it's currently running from - your path needs to be relative to that.– Synchro
Mar 23 at 18:05
I'm working on xampp localhost so how do I use the absolute path?
– MISIU
Mar 23 at 18:06
I'm working on xampp localhost so how do I use the absolute path?
– MISIU
Mar 23 at 18:06
It's the local file system path that's wrong, not a URL.
– Synchro
Mar 23 at 18:06
It's the local file system path that's wrong, not a URL.
– Synchro
Mar 23 at 18:06
|
show 14 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55315809%2fphpmailer-adding-images-using-the-for-loop%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown