无法使用RestAPI Lumen在Ubuntu Server中发送电子邮件

时间:2018-09-19 05:33:39

标签: php laravel email ubuntu lumen

我一直在Unbutu Linux Server中托管我的Lumen,现在的问题是我无法发送任何电子邮件。 在此之前,我可以通过以下方式在本地主机中发送电子邮件:

Lumen 5.3 send email

没有错误显示 Webpage display Picture

控制器:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use \Barryvdh\DomPDF\PDF;
use Barryvdh\DomPDF\Facade as domPDF;

class HomeController extends Controller
{
    public function generatePDF()

    {
        $pdf = app()->make('dompdf.wrapper');


        $data = ['title' => 'Welcome to HDTuto.com'];

        $pdf = $pdf->loadView('myPDF', $data);
        $pdf->setPaper('Letter', 'potrait');
        return $pdf->download('hdtuto.pdf');

    }
}

路线

$router->get('email', function () use ($router) {
    $data = ['username' => "test5", 'password' => "password", 'email' => "test@email.com"];

    Mail::send('emails.signup', $data, function ($mail)
    {

                $mail->to('test@yahoo.com');


                $mail->subject('Sign Up Success');
            });
    return response('yes');
});

app.php

<?php

require_once __DIR__.'/../vendor/autoload.php';

try {
    (new Dotenv\Dotenv(__DIR__.'/../'))->load();
} catch (Dotenv\Exception\InvalidPathException $e) {
    //
}


$app = new Laravel\Lumen\Application(
    realpath(__DIR__.'/../')
);

$app->withFacades(true, [ 'Illuminate\Support\Facades\Mail' => 'Mail',]);

$app->withEloquent();


$app->singleton(
    Illuminate\Contracts\Debug\ExceptionHandler::class,
    App\Exceptions\Handler::class
);

$app->singleton(
    Illuminate\Contracts\Console\Kernel::class,
    App\Console\Kernel::class
);


$app->register(\Barryvdh\DomPDF\ServiceProvider::class);
$app->register(App\Providers\AppServiceProvider::class);
$app->register(Illuminate\Mail\MailServiceProvider::class);
// $app->register(App\Providers\AuthServiceProvider::class);
$app->configure('dompdf');
$app->configure('services');
$app->configure('mail');

$app->router->group([
    'namespace' => 'App\Http\Controllers',
], function ($router) {
    require __DIR__.'/../routes/web.php';
});

return $app;

我已经尝试了多种方法来修复该问题,但不幸的是,那里还没有修复。

我认为问题是由于我的PDF生成器也无法正常工作,因此ServiceProvider全部无法正常工作

0 个答案:

没有答案