Я новичок в laravel4, я занимаюсь разработкой веб-сайта и успешно создаю функцию регистрации пользователей. После регистрации у определенного пользователя будет получена электронная почта для активации учетной записи, которая полностью работает в моем веб-приложении.
но проблема заключается в том, что код проверки, который должен отображаться как гиперссылка, не отображаться как гиперссылка, кроме Gmail, то есть у другого поставщика услуг электронной почты, такого как yahoo, outlook, GMX... этот код подтверждения не отображается как гиперссылка., только отображаемый как простой текст.
теперь вот мой файл mail.php
<?php
return array(
/*
|--------------------------------------------------------------------------
| Mail Driver
|--------------------------------------------------------------------------
|
| Laravel supports both SMTP and PHP "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 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>
Согласно вашей ситуации, я не думаю, что ошибка в 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;"> Activate Now </a>
</div>
Замените свою кнопку активации моей, и дайте мне знать, как это происходит...
Я вспомнил, когда столкнулся с этой проблемой.