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;








0















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.










share|improve this question




























    0















    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.










    share|improve this question
























      0












      0








      0








      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.










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 23 at 16:18









      MISIUMISIU

      32




      32






















          1 Answer
          1






          active

          oldest

          votes


















          0














          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.






          share|improve this answer

























          • 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 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











          • It's the local file system path that's wrong, not a URL.

            – Synchro
            Mar 23 at 18:06











          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
          );



          );













          draft saved

          draft discarded


















          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









          0














          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.






          share|improve this answer

























          • 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 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











          • It's the local file system path that's wrong, not a URL.

            – Synchro
            Mar 23 at 18:06















          0














          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.






          share|improve this answer

























          • 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 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











          • It's the local file system path that's wrong, not a URL.

            – Synchro
            Mar 23 at 18:06













          0












          0








          0







          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.






          share|improve this answer















          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.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          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 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











          • 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











          • 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











          • 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



















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript