1

I have the following code in my email template:

<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3022.6173606180814!2d-73.98784413488774!3d40.74844444332261!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x89c259a9aeb1c6b5%3A0x35b1cfbc89a6097f!2sEmpire+State+Building%2C+350+5th+Ave%2C+New+York%2C+NY+10118!5e0!3m2!1sen!2s!4v1488865918048" width="600" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>

I used yiiMailer in order to send mails to the users, and I have the following code in my controller:

$topic='Message';
$letter = $this->renderPartial('application.views.mail.email_temp',array('model'=>$model, 'topic'=>$topic, ''),true);
$message=$letter;
$mail = new YiiMailer('contact',array('message'=>$message));
$mail->setSubject('Message');

But, when I open the sent email, it is not showing Google Maps (tested with Gmail). How can I show Google Maps in my email?

Pang
  • 9,564
  • 146
  • 81
  • 122
phpdev
  • 511
  • 4
  • 22
  • This has been asked before: http://stackoverflow.com/questions/24355007/is-there-no-way-to-embed-a-google-map-into-an-html-email Also in case you haven't add $mail->IsHtml(true); to enable html email. – STiTCHiCKED Mar 07 '17 at 06:00

1 Answers1

2

You can't get JavaScript maps working in email, and Gmail won't let you embed an iframe to an email. (iFrames and JavaScript added to an email in this way would be considered a security risk.)

What you can do, however, is embed a static map image on your email.

  1. Go to http://staticmapmaker.com/google/ and enter location wanted.

  2. Copy the generated static map image and paste it the email.

  3. Copy the href from the "Map with link to Google Maps" section.

  4. Select the image you copied/pasted into your email and do command/ctrl+k to add a link to that image.

  5. Paste the url from step #3 into Web Address field.