如何从GoDaddy邮件服务器发送电子邮件

时间:2019-03-04 11:10:36

标签: php laravel email laravel-5

在Laravel项目中,我无法从GoDaddy邮件帐户发送邮件。我已在文件中提供了所有需要的值,但邮件未发送。

这是我的.env文件

MAIL_DRIVER=mail
MAIL_HOST=hostdetails
MAIL_PORT=465
MAIL_USERNAME=test@ezmoverandrental.com
MAIL_PASSWORD=testpass
MAIL_ENCRYPTION=ssl

控制器

public function estimation_form_submit_confirm()
{
    Mail::send(new SendMail());
} 

App / Mail / SendMail.php

namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Http\request;

class SendMail extends Mailable
{
    use Queueable, SerializesModels;

    public function __construct()
    {

    }

    public function build(request $request)
    {
        return $this->view('mail',['name'=>'raff'])->to('support@gmail.com')->from('info@domainName.com');
    }
}

log文件中也未显示错误。

我还需要在其他地方更改代码!!!

有人帮助吗?

1 个答案:

答案 0 :(得分:0)

================================================ ======================== 1.请使用php artisan config:clear或php artisan config:cache更新您的配置

  1. 您正在使用队列,因此您需要运行队列列表器。请运行php artisan queue:work

注意:- 注意:关闭终端后,队列将停止工作。如果希望队列继续侦听,则可以在Linux终端中运行以下命令:

nohup php工匠队列:工作&

================================================ =======================

如果您要发送简单邮件,则可以无队列发送

  1. 带有刀片文件
Mail::send('auth.emails.verify', $data, function ($message) use ($data) {
              $message->to($data['email'])
                      ->subject('Verify your email address');
});



2. without a blade

Mail::send([], [], function ($message) use ($data) {
                $message->to($data['email'])
                        ->subject('Verify your email address')
                        ->setBody('<h1>Verify Your Email Address</h1><p>You registration is successful verify your email before proceeding by clicking the link below. </p><p><a href="">Click here to activate your account .</a></p>', 'text/html');  
 });


3. Or simply text mail

 Mail::raw('Your Text', function ($message) use ($data)  {
              $message->to($data['email'])
                ->subject('Verify your email address');
  });