Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display <iframe> tag to gmail

I use codeigniter to send email... After activating the user account it sends another email to insert tag but when the user receives the message, no tag appeared but when I tried using other elements like or it renders the style but how come doesn't?

        $message = 'Congratulations! Use the script below to add your widget.<br>';
        $message .= "<iframe frameborder=\"0\" src=\"<?=base_url() ?>business/widget/{$id}\" height=\"320px;\" width=\"480px\" style=\"border: 1px solid #ccc;\"></iframe>";

        $this->email->message($message);    

        if($this->email->send())        
        { 
                         other code.... 
                    }
like image 405
user2247326 Avatar asked Jun 07 '13 05:06

user2247326


People also ask

Can you embed iframe into Gmail?

/cloudHQ Apps / Gmail Email Templates / cloudHQ Apps / HTML Editor for Gmail / Can I embed my iframe into an email? Unfortunately, iframes aren't currently supported by most email providers and iframes typically don't work in email. This is because email doesn't function the same as a web page.

Does Google support iframe?

You can embed an entire webpage as an iframe in a new Google site. This will allow you to pull in content from other websites and Google tools like Apps Script, Data Studio, and App Maker, saving you the trouble of duplicating and updating that information on your page. 2.

How do I use iframe tags?

Definition and UsageThe <iframe> tag specifies an inline frame. An inline frame is used to embed another document within the current HTML document. Tip: Use CSS to style the <iframe> (see example below). Tip: It is a good practice to always include a title attribute for the <iframe> .

How do I embed an iframe?

To embed an iframe in a content page, select Interactive layout, choose the HTML block and paste the iframe code there. You can adjust the iframe width and height properties. To embed an iframe using the Old (Classic) editor, click on the Embed Media icon and paste the code in the appropriate field.


2 Answers

Gmail and many other email clients are very strict about what HTML you can use in your HTML emails.

<iframe> is strictly off limits, because it could expose the user to a website which they were not expecting, and the website at the other end could record info about the user (such as their IP address). Images are blocked for similar reasons.

If I were you, I'd stick to using super basic HTML and CSS. Focus on getting the message to the user and hope their client makes the message look pretty. Always offer a link to view the full message elsewhere.

like image 111
Jared Avatar answered Sep 28 '22 09:09

Jared


<iframe>s cannot be used in most email clients – whether in an application or as a website. They are either stripped for one of several reasons:

  • The mail/web client could have trouble rendering it, so it is excluded.
  • An <iframe> could be used for phishing/malicious attacks, putting malicious code in what was otherwise vetted and safe (the browser/client can't see or scan what gets loaded into an iframe, it just loads it into the DOM).

An alternative, (what YouTube do), is instead of embedding something in an iframe (in their case, a video), they have an <a> wrapped around an <img> or thumbnail, which gives the impression that you are playing a video. All it does when you click on it, is it take you to that video's URL.

If you were trying to put extensive code into the email, you could manually write it in. This however has other effects, as some other tags are limited/styling can be a big hassle for emails. AFAIK some HTML5 elements are also stripped from emails.

As Orangepill said, Campaign Monitor have done the legwork and provided a chart showing where iframes can be used. They also suggest to stay away from iframes.

A solution not mentioned would be to have an image, with a link at the bottom that says View this message in a webpage which will take the user to a page with the <iframe> working.

like image 27
eggy Avatar answered Sep 28 '22 08:09

eggy