2

提交详细信息后,我想重定向回联系人页面。我查看了论坛上的解决方案,但我无法找到解决方案。

到目前为止,这就是我所拥有的:

Route::post('sendmail', function()
{
    Mail::send('emails.auth.mail', array('token'=>'SAMPLE'), function($message){
        $message = Swift_Message::newInstance();
        $email = $_POST['email']; $name = $_POST['name'];
        $message->setFrom(array($email => $name));

        $message->setTo(array('name@name.com' => 'Jim Scott')); 

        $subject = $_POST['subject'];   
        $message->setSubject($subject); 

        $msg = $_POST['msg'];   
        $message->setBody($msg);

        $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')->setUsername('username')->setPassword('pass');

        $transport->setLocalDomain('[127.0.0.1]');

        $mailer = Swift_Mailer::newInstance($transport);

        $result = $mailer->send($message);

        if($result) {
            return Redirect::to(URL::previous())->with('success', 'You have posted successfully');
        }
    });
});

这会将结果正确发送到指定的电子邮件地址,但仍保留在“/sendmail”页面上。

4

1 回答 1

4

你有没有尝试过:

return Redirect::back()->with('success', 'You have posted successfully');

?

于 2013-07-27T15:01:59.867 回答