使用 mailgun 和 Laravel 发送电子邮件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22312769/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Sending emails with mailgun and Laravel
提问by David Mckee
I am trying to learn how to send emails using Mailgun in Laravel. When I try to send the email I get a timeout that says: Maximum execution time of 60 seconds exceeded The application times out here:
我正在尝试学习如何在 Laravel 中使用 Mailgun 发送电子邮件。当我尝试发送电子邮件时,我收到一个超时消息:超过 60 秒的最大执行时间应用程序在此处超时:
$line = fgets($this->_out);
I have a route that activates when I click a button on my email page:
当我单击电子邮件页面上的按钮时,我有一个激活的路由:
Route::post('/email', 'MainController@sendEmail');
Here is my controller function (replaced my email for privacy reasons):
这是我的控制器功能(出于隐私原因替换了我的电子邮件):
public function sendEmail() {
$data = [
'title'=>'Email'
];
Mail::send('emails.hello', $data, function($message) {
$message->from('[email protected]', 'Example Person');
$message->to('[email protected]')->subject('we made it');
});
return Redirect::to('/');
}
Any ideas on what I may do be doing wrong?
关于我可能做错了什么的任何想法?
回答by Suresh Bala
This generally happens if the SMTP port used in the app/config/mail.php config file is not opened by your hosting provider. Please check and ask them to open the port. This should resolve the issue.
如果您的托管服务提供商未打开 app/config/mail.php 配置文件中使用的 SMTP 端口,则通常会发生这种情况。请检查并要求他们打开端口。这应该可以解决问题。
回答by Chris Goosey
Sending emails through mailgun could not be simpler, just add the API package, publish and update the config and use the custom facade to send them (changing Mail::send() to Mailgun::send())
通过 mailgun 发送电子邮件再简单不过了,只需添加 API 包,发布和更新配置并使用自定义外观发送它们(将 Mail::send() 更改为 Mailgun::send())
You can find the package here: http://packalyst.com/packages/package/vtalbot/mailgun
你可以在这里找到这个包:http: //packalyst.com/packages/package/vtalbot/mailgun
I know this doesn't really address the error your getting (would need more information to help with that), but using the package does simplify the whole thing!
我知道这并不能真正解决您遇到的错误(需要更多信息来帮助解决此问题),但是使用该包确实可以简化整个过程!