【问题标题】:laravel4 hyperlink is not showing in yahoo,outlook but in gmail hyperlink is workinglaravel4 超链接未在 yahoo、outlook 中显示,但在 gmail 中超链接有效
【发布时间】:2014-12-14 01:03:07
【问题描述】:

我是 laravel4 的新手,我正在开发一个网站并成功创建用户注册功能。注册后,特定用户将收到一封用于激活帐户的电子邮件,这在我的网络应用程序中绝对可以正常工作。

但问题是,验证码应该显示为超链接,而不是显示为超链接,除了 Gmail,即在其他电子邮件服务提供商(如 yahoo、outlook、GMX...)中未显示为超链接。仅显示为纯文本。

现在这是我的 mail.php 文件

<?php

return array(

/*
|--------------------------------------------------------------------------
| Mail Driver
|--------------------------------------------------------------------------
|
| Laravel supports both SMTP and PHP's "mail" function as drivers for the
| sending of e-mail. You may specify which one you're using throughout
| your application here. By default, Laravel is setup for SMTP mail.
|
| Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill", "log"
|
*/

'driver' => 'smtp',

/*
|--------------------------------------------------------------------------
| SMTP Host Address
|--------------------------------------------------------------------------
|
| Here you may provide the host address of the SMTP server used by your
| applications. A default option is provided that is compatible with
| the Mailgun mail service which will provide reliable deliveries.
|
*/

'host' => 'mail.forgroup.com',

/*
|--------------------------------------------------------------------------
| SMTP Host Port
|--------------------------------------------------------------------------
|
| This is the SMTP port used by your application to deliver e-mails to
| users of the application. Like the host we have set this value to
| stay compatible with the Mailgun e-mail application by default.
|
*/

'port' => 465,

/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all e-mails sent by your application to be sent from
| the same address. Here, you may specify a name and address that is
| used globally for all e-mails that are sent by your application.
|
*/

'from' => array('address' => '******@*******.com', 'name' => '*******'),

/*
|--------------------------------------------------------------------------
| E-Mail Encryption Protocol
|--------------------------------------------------------------------------
|
| Here you may specify the encryption protocol that should be used when
| the application send e-mail messages. A sensible default using the
| transport layer security protocol should provide great security.
|
*/

'encryption' => 'ssl',

/*
|--------------------------------------------------------------------------
| SMTP Server Username
|--------------------------------------------------------------------------
|
| If your SMTP server requires a username for authentication, you should
| set it here. This will get used to authenticate with your server on
| connection. You may also set the "password" value below this one.
|
*/

'username' => '******',

/*
|--------------------------------------------------------------------------
| SMTP Server Password
|--------------------------------------------------------------------------
|
| Here you may set the password required by your SMTP server to send out
| messages from your application. This will be given to the server on
| connection so that the application will be able to send messages.
|
*/

'password' => '*******',

/*
|--------------------------------------------------------------------------
| Sendmail System Path
|--------------------------------------------------------------------------
|
| When using the "sendmail" driver to send e-mails, we will need to know
| the path to where Sendmail lives on this server. A default path has
| been provided here, which will work well on most of your systems.
|
*/

'sendmail' => '/usr/sbin/sendmail',

/*
|--------------------------------------------------------------------------
| Mail "Pretend"
|--------------------------------------------------------------------------
|
| When this option is enabled, e-mail will not actually be sent over the
| web and will instead be written to your application's logs files so
| you may inspect the message. This is great for local development.
|
*/

'pretend' => false,

);

虽然我不知道,这个错误的原因是什么,我试图更改我的 mail.php 文件中的端口。以前我的端口值为 465,将其更改为 25 后,我收到以下错误,所以我回到了我以前的端口,即 465

Swift_TransportException
Connection could not be established with host mail.foragroup.com [ #0]

之后我尝试了另一种加密“tls”而不是“ssl”,但之后我面临以下错误

Swift_TransportException
Connection to tcp://mail.forgroup.com:465 Timed Out

现在虽然我不清楚,但我给你我的控制器,实际上我是通过它发送验证邮件的,这里是控制器

public function signupPost()
{
    $validator = Validator::make(Input::all(), array(

        'email'             => 'required|max:255|email|unique:users',
        'username'          => 'required|min:4|unique:users',
        'password'          => 'required|min:8',
        'password_again'    =>  'required|same:password'

        )
    );

    if($validator->fails())
    {
        return Redirect::route('signup')
            ->withErrors($validator)
            ->withInput();
    }else
    {
        $email          = Input::get('email');
        $username       = Input::get('username');
        $password       = Input::get('password');

        //Activation Code
        $code = str_random(60);

        $user = User::create(array(
                    'email'     => $email,
                    'username'  => $username,
                    'password'  => Hash::make($password),
                    'code'      => $code,
                    'active'    => 0                
                    )
        );

        if($user){
            //User Activation Code Creation
            Mail::send('emails.auth.activate', array('link' => URL::route('activate-account',$code), 'username' => $username),function($message) use ($user)
                {
                    $message->to($user->email,$user->username)->subject('Activate Your Account');
                });

            return Redirect::route('signup')
                            ->with('global','Your Account has been created! We have sent you an email to activate your account.Please Check the both the Inbox and Spam Folder.');

        }

    }



}

更新

这是我的激活 HTML 文件

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title></title>
</head>
<body>
<h3>Hello <strong><h1 style="color:#1B438D">{{$username}}</h1></strong></h3> <br><br>
    Please Activate Your Account Using The Following Link <br><br>

<b>NOTE</b><h3 style="color:red;">If the following code is not a link or clickable,then please              <b>COPY</b><br/>
the whole code and <b>PASTE</b> it in NEW TAB of your browser.</h3> 


----
{{$link}}
----

</body>
</html>

【问题讨论】:

  • 您的结果电子邮件内容类型是 text/plain 还是 text/html?
  • 你说的是实际包含邮件消息或正文的html文件吗?
  • 你还有这个问题吗?
  • 你能帮我解决这个问题吗@evoque2015
  • 我认为错误出在 email/auth/activate 视图中。你如何设计你的激活按钮?你能在你的帖子上更新吗?把那个视图给我,我帮你看看。这很容易解决 - 不用担心

标签: php email laravel-4


【解决方案1】:

根据你的情况,我认为错误不在mail.php,否则你将无法发送任何电子邮件。

我怀疑错误出在email/auth/activate.blade.php

比较我的和你的并注意差异。

这是我如何设置激活按钮的样式,它适用于所有电子邮件客户端。 我已经使用 Google、Outlook 等进行了测试。

<div style="font-family: Arial, sans-serif; color: #90bc26; font-size: 13px;">
      <a target="_blank" href="http://{{ str_replace("http://","",$link); }}" style="color: #ffffff; text-decoration: none; margin: 0px; text-align: center; vertical-align: baseline; border: 4px solid #90bc26; padding: 4px 9px; font-size: 15px; line-height: 21px; background-color: #90bc26;">&nbsp; Activate Now &nbsp;</a>
    </div>

用我的替换你的激活按钮,然后告诉我它是怎么回事......

我记得我遇到这个问题的时候。

【讨论】:

  • 对不起,它在实时服务器中不起作用,但在本地服务器中,激活链接显示为超链接(在 yahoo、gmail 中),但单击链接后,会出现一个弹出窗口并发出警告“链接包含错误的网址格式”,但我担心它仍然无法在实时服务器中工作,我实际上正在使用 Cpanel。
  • Rego,编辑您的帖子,并显示您的确切错误。如果可以,请截屏。我会帮你调试的。
  • evoque2015,我已经更新了我的帖子,提到,根据您的回答,在我的本地服务器中一切似乎都很好,但在实时服务器中没有任何改变。我已经在上面给出了我的激活 html。如果你需要更多的代码,然后请教我。
  • 我上面给出的激活 HTML 文件是旧文件。但是根据您的回答更改链接按钮后,似乎它在每个电子邮件服务提供商中都有效。但我尝试使用 Yahoo,那里点击超链接后,弹出窗口警告我网站地址格式不标准。
猜你喜欢
  • 2014-05-15
  • 2017-10-03
  • 2021-07-14
  • 2013-07-14
  • 2011-09-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多