【问题标题】:Laravel email template URLs not working in GmailLaravel 电子邮件模板 URL 在 Gmail 中不起作用
【发布时间】:2016-01-17 20:33:15
【问题描述】:

我正在使用 Laravel 4 smtp 邮件向用户发送邮件。当我向 Gmail 发送邮件时,徽标和 URL 未按预期显示。当我检查网址时,它显示的是 localhost 而不是我的域名。我不知道为什么会这样。

我的电子邮件模板:

<!DOCTYPE html>
<html lang="en-US">
    <head>
        <meta charset="utf-8">
        <link href='https://fonts.googleapis.com/css?family=Dosis:400,500,600,700' rel='stylesheet' type='text/css'>
        <style>
        body {
            font-family: 'Dosis', sans-serif;
            font-size:14px;
            color: #333;
        }
        #table-wrap {
            background:#fafafa;
            border-bottom: 5px solid #eee;
            border-top: 5px solid #EC4F48;
        }
        #site_logo{
            background: #EC4F48; 
            border-bottom: 2px solid #EC4F48;
            -webkit-border-bottom-right-radius: 2px;
            -webkit-border-bottom-left-radius: 2px;
            -moz-border-radius-bottomright: 2px;
            -moz-border-radius-bottomleft: 2px;
            border-bottom-right-radius: 2px;
            border-bottom-left-radius: 2px;
        }
        </style>        
    </head>
    <body>
        <table id="table-wrap" width="100%" cellpadding="0" cellspacing="0" style="border-radius:3px; -webkit-border-radius:3px; -moz-border-radius:3px;">
            <tbody>
                <tr>
                    <td align="left" style="padding:3px; border-bottom: 2px solid #fadc65;" width="60%">
                        <h3 style="margin-left: 15px;">Hi, {{{ $username }}}!</h3>
                    </td>
                    <td align="center" id="site_logo">
                        <img src="{{ asset('dist/img/logo.png') }}" width="200" style="margin-left: 10px;" />
                    </td>
                </tr>
                <tr>
                    <td align="center" colspan="2">
                        <br />
                            <h2>Welcome to mydomain.com !</h2>
                            <h2>Thanks for registering to Mysite.</h2>
                            <h4><a href="{{ url('user/verify/'.$code) }}" target="_blank">Click here to confirm your email...</a></h4>
                        <br />
                    </td>
                </tr>
                <tr>
                    <td align="left">
                        <p style="margin-left: 20px; color: #666;">
                         www.mydomain.com&nbsp; | &nbsp;Email : feedback@mydomain.com
                        </p>
                    </td>
                </tr>
            </tbody>
        </table>


    </body>
</html>

【问题讨论】:

  • 您使用 CLI 发送此电子邮件还是在浏览器中触发?
  • @l3ehnam 是的,它的 CLI。我为此做了一个工作。

标签: php email laravel-4 gmail html-email


【解决方案1】:

当你使用 CLI 生成任何视图时,Laravel 使用url 参数来设置域。默认情况下,它的值设置为http://localhost,因此您需要将此参数更改为您的域。

参数位于config文件夹中的app.php

应用程序 URL 的 Laravel 注释: This URL is used by the console to properly generate URLs when using the Artisan command line tool. You should set this to the root of your application so that it is used when running Artisan tasks.

【讨论】:

  • 这不是答案
猜你喜欢
  • 1970-01-01
  • 2019-02-08
  • 2021-06-22
  • 1970-01-01
  • 1970-01-01
  • 2015-03-28
  • 2014-06-03
  • 1970-01-01
  • 2016-05-11
相关资源
最近更新 更多