Sunday 15 January 2012

html - How to insert an image in php mail? -


How do I insert an image into a PHP mail form?

I have this code:

  $ headers = 'MIME-Version: 1.0' "\ N"; $ Headers = 'Content-type: text / html; Charset = "UTF-8" '\ n ". $ Headers = 'To: text@example.fr'; $ Image = "http://lcda.fr/site/abonnement/img/logo.png"; // Echriston du Message $ message. = '& Lt; Img src = ". $ Image." & Gt; '; $ Message = '& Lt; P & gt; & Lt; Br / & gt; Voter commands take a bienà © ÃÆ'à ¢ â,¬Å¡Ãƒâ € šÃ, © / under number: / Span & gt; & Lt; B & gt; (Referee - '. $ _ Session [' refvb '].') & Lt; / B & gt; & Lt; / P & gt; '; $ Message = '& Lt; Width of table = "500" & gt; '; $ Message = '& Lt; Tr & gt; & Lt; Th colspan = "2" align = "left" & gt; Notifications abonnement / & lt; Span style = "color: blue" & gt; Subscription notifications & lt; / Span & gt; & Lt; / Th & gt; & Lt; / TR & gt; '; $ Message = '& Lt; Tr & gt; & Lt; Td width = "250" & gt; Abonnement / & lt; Span style = "color: blue" & gt; Subscribe & lt; / Span & gt; : & Lt; / Td> & Lt; Td> '. $ Infoabo ['abo']. ' & Lt; / Td> & Lt; / Tr & gt; '; $ Message = '& Lt; Tr & gt; & Lt; Td> Dure © E / & lt; Span style = "color: blue" & gt; & Lt; / Span & gt; : & Lt; / Td> & Lt; Td> '$ Infoabo [' duree '].' One (s) & lt; / Td> & Lt; / Tr & gt; '; $ Message = '& Lt; Tr & gt; & Lt; Td> Quantity / & lt; Span style = "color: blue" & gt; Amount of & lt; / Span & gt; : & Lt; / Td> & Lt; Td> '. $ Infoabo ['quantite']. ' & Lt; / Td> & Lt; / Tr & gt; '; $ Message = '& Lt; Tr & gt; & Lt; Td> Localization / & lt; Span style = "color: blue" & gt; Localization & lt; / Span & gt; : & Lt; / Td> & Lt; Td> '$ Infoabo [' zone '].' & Lt; / Td> & Lt; / Tr & gt; '; $ Message = '& Lt; Tr & gt; & Lt; Td> Prix ​​/ & lt; Span style = "color: blue" & gt; The value of the & lt; / Span & gt; : & Lt; / Td> & Lt; Td> '$ Infoabo [' prix '].' One ?? ¬ & lt; / TD & gt; & Lt; / TR & gt; '; $ Message = '& Lt; Tr & gt; & Lt; Td> Commencer l \ 'abonnement au prochain numà © ro / & lt; Span style = "color: blue" & gt; Start membership in next issue & lt; / Span & gt; : & Lt; / Td> & Lt; Td> '. $ Startabo. ' & Lt; / Td> & Lt; / Tr & gt; '; $ Message = '& Lt; / Table & gt; '; } $ Message = '& Lt; Br> & Lt; P & gt; & Lt; B & gt; Mode Day Permutation / & lt; Span style = "color: blue" & gt; Make Payment & lt; / Span & gt; : '. $ Mode; $ Message = '& Lt; / P & gt; '; $ Message = ''; // envoie du mail ini_set ("sendmail_from", 'test@example.fr');   

But does the image not load? Is there any other way to do this? (This issue is to keep the logo company, where the image is placed)

need to host your image Is a public URL which is then used in email

for example

  $ image = 'http: //cdn.mydomain.tld/image.png ';   

Update:

As the user has posted (therefore give credit), your string consensus is wrong (though its correction is wrong) so that your < The code> $ image path will not be in your string.

You must

  // correct $ string = '& lt; Img src = "'. $ Image is required." & Gt;' = //; & gt; & lt; img src = "image.png" & gt; wrong $ string = '& lt; img Src = ". $ Image. "& Gt; '; // = & gt; & lt; img src =" $ image "& gt;   

Add additional ' Note the single quotation marks You are not breaking out of the string to add the variable, and PHP does not parse it for interpolation due to being engraved in a single quote. < / Html>

No comments:

Post a Comment