2015-04-03 42 views
0

我已經能夠使用Laravel 5和Mailgun的組合成功發送電子郵件給自己,但是當我嘗試更改時,出現令人沮喪的「不良請求」錯誤只是一行代碼。具體而言,當我將此行更改爲:只能使用Laravel 5和Mailgun向自己發送電子郵件

$ message-> to('[email protected]')發送給我的Mailgun帳戶使用的郵件時,我收到了錯誤的請求錯誤。這是我改變的唯一的事情。

編輯(這裏是我的代碼):

Mail::send('emails.alerts.assess_tomorrow', $view_data, function($message) { 
$message->to('[email protected]')->subject('test 23')->from('[email protected]'); 
      }); 

EDIT2(我mail.php代碼):

<?php 

return [ 

     'driver' => 'mailgun', 
     'host' => 'smtp.mailgun.org', 
     'port' => 587, 
     'from' => ['address' => '[email protected]', 'name' => 'A Name'], 
    'encryption' => 'tls', 
     'username' => 'my mailgun postmaster username', 
     'password' => 'my mailgun password', 
    'sendmail' => '/usr/sbin/sendmail -bs', 
    'pretend' => false, 

]; 

我已經安裝了狂飲和更新laravel。正如我所提到的,當「收件人」電子郵件位於我自己(我的mailgun帳戶使用的地址)時,此功能可以完美實現。

換句話說,我只能發郵件給自己。所以我知道代碼基本上正在工作,但它似乎更改「到」地址(例如我的Gmail地址),導致錯誤的請求錯誤。

我錯過了一些明顯的東西嗎?非常感謝任何想法!

+0

將您的發送電子郵件代碼添加到問題 – 2015-04-03 15:22:13

+0

[在laravel錯誤中使用mailgun發送電子郵件時可能的重複](http://stackoverflow.com/questions/28286445/sending-email-with-mailgun-in-laravel-error ) – ceejayoz 2015-04-03 15:23:34

回答

1

已解決!我是一個栗色的人。我沒有注意到我的郵件帳戶需要驗證,才能發送電子郵件到其他地址。

我登錄到mailgun併發送激活郵件。帳戶激活後,所有內容都可以正常工作。抱歉花點時間,但也許這可能會幫助其他任性的人!

相關問題