我是Laravel 4的菜鸟和接触形式的东西让我有些麻烦使它工作 . 发现很少的东西,都使用控制器,但我只需要在路线中 .
如何使用简单的联系表单(姓名,电子邮件和消息)将路径发送到管理电子邮箱?
干杯
这是使用您的路线发送电子邮件的快速而肮脏的方式:
创建您的路线
Route::get('contact', function() { return View::make('contact'); }); Route::post('contact', function() { $fromEmail = Input::get('email'); $fromName = Input::get('name'); $subject = Input::get('subject'); $data = Input::get('message'); $toEmail = 'manager@company.com'; $toName = 'Company Manager'; Mail::send('emails.contact', $data, function($message) use ($toEmail, $toName, $fromEmail, $fromName, $subject) { $message->to($toEmail, $toName) $message->from($fromEmail, $fromName); $message->subject($subject); }); });
创建 app/views/contact.php
app/views/contact.php
<html> <body> <form action="/contact" method="POST"> Your form </form> </body> </html>
创建 app/views/emails/contact.php
app/views/emails/contact.php
<html> <body> Message: {{$data}} </body> </html>
你需要配置
app/config/mail.php
1 回答
这是使用您的路线发送电子邮件的快速而肮脏的方式:
创建您的路线
创建
app/views/contact.php
创建
app/views/emails/contact.php
你需要配置