skip to Main Content

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


  1. 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,

    <html>
    Hello
    <br><br>
    <svg>
        <use xlink:href="#A" />
        <symbol id="A">
            <ellipse cx="50" cy="25" rx="50" ry="25" />
        </symbol>
    </svg>
    <br>
    Best Regards, Sender
    </html>
    

    The following is what the user will see thru the above code :

    enter image description here

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

    <html>
    Hello
    <br><br>
    <img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAAyACsDASIAAhEBAxEB/8QAGwAAAQUBAQAAAAAAAAAAAAAAAAIFBgcIAwT/xAArEAABAwMDAwMDBQAAAAAAAAABAgMEAAURBgchEjFRMkFhIkJScYGxwdH/xAAaAQACAwEBAAAAAAAAAAAAAAACAwEEBQYA/8QAIREAAgICAgIDAQAAAAAAAAAAAQIAAwQxEUESUQUTFCH/2gAMAwEAAhEDEQA/ANO9Q815J02NAjOSZCw2hIySTikzpbUGK488oJQkZ596p7U+o5WoZ6WIoUI4OENjus1TzMxMdeNt0JofH4D5jc6QbMuO1z49xjJkRlhSFdiDXr6hnGeajGhra/a7CyxJ4dJKinxmnuFNjS+ox3m3SlWFdJzg0+lmesMw/sqXqiWFUPI6M91FFFNipS+4l3nSLoqK4FNR0elH5fNPe2VpglgzlKS9L/En0VKdUacj3iErKQJCR9DnvVSMPXDSd8IypJScEY+lwfFYF1Zxsj7rRys63Fdc/B/PQfFx17l23Nt56A83FWUPrQUpV4OO9ZA0drW87baxkszW33GVPqEqM4Tkgn1jPvj+K1xZLq1dLc1Ma+4YKfBqDbw7cQdXWl2W0W4tzjoK0PngKA5KVfH+1vVMHXyGjOTdGRyG2JN9NX6HqO0M3C1SUPsPDOUnPQfBp4So9IyOaxJtpra47f39aWlF6AVlMmMDkE5x1J+e3ArZ9pmtT7ZFmMhwNyG0upC0kKAUM8j96IgiCCDPWeMYHBpg1Np6Pe4y0OBKXx6HMcipHSFAmlW1ravi0ZVY1Th0PBEYNLWcWO0JjOuBakkqUrtWe98d1V3R16waddWiGlRRIfQeXD+KffFaWusdUqA9HB6VOoUjqzjGRVHbVbLqt16kXPVKWXlNPKVGZSSUnnIUoUdahAB6g2u1rln2e427HbSqWWb/AKpZGM9caKvnPHC1fPxWjm0hLaQkAADAAGK5toCW0jox08BKewFdxjFETzAC8RVJNFFR3JOpzc5xnzSMDJ4Hf+qKKXZueWLVwg48V1T6R+lFFEIRn//Z" />
    
    <br>
    Best Regards, Sender
    </html>
    

    enter image description here

    Login or Signup to reply.
  2. 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,

    define("SITE_URL", "https://DomainName.cc");
    

    You can use it in email body as,

       $mail->MsgHTML( "<p><img src='" . SITE_URL . "/Form-Logo.svg' width='250'> " . "</p>" );
    

    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,

    <img id="img" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASAB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FnRAREQEREBERAREQEREBERAREQEREBERAREQEREBERAREQEREBERAREQEREBERAREQEREBERAREQEREBERAREQEREBERAREQEREBERAREQEREBERAREQEREBERAREQEREBERAREQEREBERAREQEREBERAREQEREBERAREQEREBERAREQEREH/9k=" width="200" height="200" />
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search