나는 localhost에서 이메일을 보내는 것을 테스트하기 위해 몇 번이고 시도하지만 나는 여전히 할 수 없다. 나는 그것을하는 방법을 더 이상 모른다. 해결책을 찾기 위해 검색을 시도하지만 찾을 수는 없습니다. config/mail.php를 편집했습니다 :
<?php
return [
/*
|--------------------------------------------------------------------------
| 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", "ses", "log"
|
*/
'driver' => env('MAIL_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' => env('MAIL_Host', 'smtp.gmail.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' => env('MAIL_PORT', 587),
/*
|--------------------------------------------------------------------------
| 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' => ['address' => '[email protected]', 'name' => 'Do not Reply'],
/*
|--------------------------------------------------------------------------
| 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' => env('MAIL_ENCRYPTION', 'tls'),
/*
|--------------------------------------------------------------------------
| 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' => env('MAIL_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' => env('MAIL_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 -bs',
/*
|--------------------------------------------------------------------------
| 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,
];
`
그리고 나는 이미 이렇게 .env
파일을 편집했습니다 :
MAIL_DRIVER=smtp
MAIL_Host=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=password
MAIL_ENCRYPTION=null
먼저 gmail 계정에 로그인하여 My account > Sign In And Security > Sign In to google
아래에서 two step verification
를 사용하도록 설정하면 app password
를 생성 할 수 있으며 .env
파일에서 해당 앱 비밀번호를 사용할 수 있습니다.
.env
파일은 다음과 같이 보입니다.
MAIL_DRIVER=smtp
MAIL_Host=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=apppassword
MAIL_ENCRYPTION=tls
php artisan config:cache
파일을 변경 한 후에 .env
를 실행하는 것을 잊지 마십시오.
다음 권장 사항에 따라 smtp 드라이버 대신 sendmail 을 사용해보십시오. http://code.tutsplus.com/tutorials/sending-emails-with-laravel-4-gmail--net-36105 )
MAIL_DRIVER=sendmail
MAIL_Host=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=apppassword
MAIL_ENCRYPTION=tls
단지 you.env 파일에서 편집하면됩니다.
MAIL_DRIVER=smtp
MAIL_Host=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=<your_email_address>
MAIL_PASSWORD=<your_gmail_app_password_>
MAIL_ENCRYPTION=ssl
앱 비밀번호 goto https://support.google.com/accounts/answer/185833?hl=ko
앱 파사드를 genearate하고 나중에 사용할 수 있도록 저장하십시오. 일단 앱 비밀번호를 생성하면 비밀번호를 다시 편집하거나 동일한 앱 비밀번호를 변경할 수 없기 때문에 (여러 앱 비밀번호를 만들 수 있습니다)
이것은 내가 시도한 샘플 작동합니다 :
config
폴더 아래에서 mail.php
를 연 다음이 옵션을 채우십시오.
'driver' => env('MAIL_DRIVER', 'smtp'),
'Host' => env('MAIL_Host', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' =>'[email protected]', 'name' => 'Email_Subject'],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME','[email protected]'),
'password' => env('MAIL_PASSWORD','youremailpassword'),
'sendmail' => '/usr/sbin/sendmail -bs',
root
프로젝트에서 .env
파일을 엽니 다. 위의 옵션을 따라이 파일을 편집하십시오.
MAIL_DRIVER=smtp
MAIL_Host=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=youremailusername
MAIL_PASSWORD=youremailpassword
MAIL_ENCRYPTION=tls
그런 다음이 명령을 실행하여 구성을 지우십시오.
php artisan config:cache
로컬 서버 다시 시작
컨트롤러에 메일 기능이 포함 된 경로를 처음 방문하면 오류가 계속 발생합니다. Authentication Required
. 신뢰할 수없는 연결을 승인하려면 Gmail 계정을 통해 로그인해야합니다. 방문 링크 권한 부여
모든 설정을 올바르게 설정 한 후에도 메일을 보낼 수 있고 금지 또는 시간 초과 오류가 발생하면 gmail에서 allow less secure apps to access your account
를 설정할 수 있습니다. 당신은 여기 를 따라갈 수 있습니다.
다양한 조합을 시도한 후에 저를 위해 일합니다.
MAIL_DRIVER=smtp
MAIL_Host=smtp.gmail.com
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=passowrd
MAIL_ENCRYPTION=ssl
응용 프로그램 암호 https://myaccount.google.com/security 및 MAIL_PASSWORD
환경 변수로 생성해야합니다.
Google 서버에서 오류 코드를 확인하여이 사실을 알았습니다.이 오류 코드는 사용이 가득 찼습니다. this 웹 페이지로 안내합니다.
귀하의 MAIL_PASSWORD=must a APPpasword
변경 후 . env 서버를 중지 한 다음 구성을 지우십시오 php artisan config : cahce 그리고 다시 서버를 시작하십시오
참조 laravel 5.2에서 보낸 사람 주소없이 메시지를 보낼 수 없습니다. enen과 mail.php를 모두 설정했습니다
나에게있어서 문제는 어떤 이유로 사용자 이름/암호가 메일 구성에서 NULL이되었다는 것입니다. 다음 코드를 이메일로 보내기 전에 확인하십시오.
dd(Config::get('mail'));
귀하의 사용자 이름/암호가 다음과 같이 설정되면 무시됩니다 :
Config::set('mail.username', 'yourusername');
Config::set('mail.password', 'yourpassword');
블루 호스트에서 나는 암호를 재설정 할 수 없었다. 이 드라이버가 작동했습니다 :
MAIL_DRIVER=sendmail
XAMPP로 개발중인 경우 전자 메일을 보내려면 SMTP 서비스가 필요합니다. MailGun 계정을 사용해보십시오. 무료이며 사용하기 쉽습니다.
전자 메일 암호를 사용하는 경우 응용 프로그램 암호로 바꾸어야합니다 .PP 암호를 설정하려면 암호를 설정하기 전에 2 단계 인증을 사용해야 나중에 비활성화 할 수 있습니다.
또한 섹션을 설정하는 데 보안이 취약한 앱을 허용했는지 확인하십시오. 추가 정보를 얻으려면 다음을 수행 할 수 있습니다. 여기