dqzow3859 2016-09-17 18:38
浏览 38

无法使用laravel php发送邮件

I am unable to send a test mail. I am using laravel php.

my .env file:

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=ca**********4b
MAIL_PASSWORD=04**********7b
MAIL_ENCRYPTION=tls

my mail.php:

'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'mailtrap.io'),
'port' => env('MAIL_PORT', 2525),
'from' => ['address' =>'******@gmail.com', 'name' => '****'],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('ca**********4b'),
'password' => env('04**********7b'),
'sendmail' => '/usr/sbin/sendmail -bs',

my controller:

<?php

namespace App\Http\Controllers;

use Request;
use Response;
use App\Users;
use Mail;

class MailController extends Controller
{
public function basic_email(){
  $data = array('name'=>"Virat Gandhi");

  Mail::send(['text'=>'welcome'], $data, function($message) {
     $message->to('******@gmail.com', '*****')->subject
        ('Laravel Basic Testing Mail');
     $message->from('"******@gmail.com','Virat Gandhi');
  });
  return "Basic Email Sent. Check your inbox.";
    }
  }

i am getting this error:

Swift_TransportException in AbstractSmtpTransport.php line 383: Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required "

tried clearing cache by php artisan config:cache

what do i need to try more?

  • 写回答

1条回答 默认 最新

  • dougekui1518 2016-09-17 19:04
    关注

    I believe it's gonna be firewall issue, have you tried to connect to gmail provider ? it's a good way to catch the error

    评论

报告相同问题?

悬赏问题

  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复