2017-05-22 76 views
0

SMTP(認証なし)で電子メールを送信しようとしています。 はここに私の.envの設定です:あなたは、TLS暗号化とは、認証を見ないし、同じサーバー上でできるよう(Laravelなし)PHPMailerを経て、Laravel 5.3 - SwiftMailerエラー:503 AUTH first(#5.5.1)

MAIL_DRIVER=smtp 
MAIL_HOST=localhost 
MAIL_PORT=587 
MAIL_USERNAME=null 
MAIL_PASSWORD=null 
MAIL_ENCRYPTION=tls 

私のメールサーバーのニーズ、私は正確に電子メールを送信することができます。実際には、私は(mailableを使用)Laravelを経由してメールを送信しようとすると、私は次のエラー受け取る、ということである:私は空のユーザ名とパスワード、SSL暗号化、暗号化なし、異なるポートを試してみました

Swift_TransportException in AbstractSmtpTransport.php line 383: 
Expected response code 250 but got code "503", with message "503 AUTH first (#5.5.1) 
" 

を..私はLaravel経由で電子メールを送ることはできません。

ここでは、私のmailableの構造を見るとメソッドを構築することができます:

public $customerName; 
public $customerEmail; 
public $emailSubject; 
public $emailMessage; 


public function __construct($customerName, $customerEmail, $emailSubject, $emailMessage) 
    { 
     $this->customerName = $customerName; 
     $this->customerEmail = $customerEmail; 
     $this->emailSubject = $emailSubject; 
     $this->emailMessage = $emailMessage; 
    } 


public function build() 
    { 
     return $this->view('emails.send'); 
    } 

私が/何か間違ったことをやって何かが足りないのですか?私はこのための解決策を見つけることができないようです。

ありがとうございます。

+0

、ユーザー名とパスワードを与えてみてください。 – Webinion

答えて

0

認証なしでメールを送信することができます。私は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", "sendmail", "mailgun", "mandrill", "ses", 
|   "sparkpost", "log", "array" 
| 
*/ 

'driver' => env('MAIL_DRIVER', 'sendmail'), 

/* 
|-------------------------------------------------------------------------- 
| 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.mailgun.org'), 

/* 
|-------------------------------------------------------------------------- 
| 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' => env('MAIL_FROM_ADDRESS', '[email protected]'), 
    'name' => env('MAIL_FROM_NAME', 'Whatever'), 
], 

/* 
|-------------------------------------------------------------------------- 
| 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(null), 

'password' => env(null), 

/* 
|-------------------------------------------------------------------------- 
| 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', 

/* 
|-------------------------------------------------------------------------- 
| Markdown Mail Settings 
|-------------------------------------------------------------------------- 
| 
| If you are using Markdown based email rendering, you may configure your 
| theme and component paths here, allowing you to customize the design 
| of the emails. Or, you may simply stick with the Laravel defaults! 
| 
*/ 

'markdown' => [ 
    'theme' => 'default', 

    'paths' => [ 
     resource_path('views/vendor/mail'), 
    ], 
], 

]; 

そして、それを送信するための

:あなたは認証なしでメールを送信することはできません

$userArr = array();  
Mail::send('mail.yourviewname', $userArr, function($message) use ($userArr) { 
       $message->bcc('[email protected]', 'Someone'); 
       $message->to($userArr['email'] , $userArr['name'])->subject('Blah blah'); 
       $message->from('[email protected]','Whatever'); 
      }); 
+0

私は電子メールを送信するために郵便銃を使用しています。 Btwの設定はほぼ同じで、なぜ認証なしで送信できないのか理解できません。 –

関連する問題