I added a banner that shows on top of contact form results Emails. However, if I don’t add the https://DomainName.cc/ before Form-Logo.svg, the banner doesn’t show in the Emails. How can I get the banners to show without adding the https://DomainName.cc/?
$mail->MsgHTML(
"<p><img src='https://DomainName.cc/Form-Logo.svg' width='250'> " . "</p>" .
2
Answers
Assuming that the email client of the mail recipient supports HTML email (Nowadays nearly all email clients do), then you may use
<svg></svg>
tag to embed the svg data(A) For example,
The following is what the user will see thru the above code :
(B) On the other hand, if you are not inserting SVG , but say inserting jpg/png, then you may use base64 to embed the data
The following is a sample code showing embedding a small "logo" graphic :
Email body is separately dynamic code, which runs independently as HTML only.
So, the "img" tag should have absolute URL for "src" attribute.
If you consider to fix this issue, you might want to have any constant defined for your site url or any such function which can generate the site url. This dynamic site url can be prepended in your email body code.
For e.g., you have saved the constants in constant.php which you are loading in every page.
There you can have something like,
You can use it in email body as,
There is another option "Base64 Encoding"
However this can increase the email size, which may impact the delivery by autoblock your email with base64 filtering applied. This does not happen always.
Adding the example below,