Laravel 4.2 mail send, redirect with flash data issue - laravel-4

I'm trying to create a simple contact form but unfortunately having some trouble getting the flash data to show once redirected.
Mail::send('emails.contact', $data, function($message) {
$message->to('support#domain.com', Input::get('name'))
->subject('Contact Form');
});
Mail::send('emails.received', $data, function($message) {
$message->to(Input::get('email'), 'Website Owner')
->subject('Message received');
});
return Redirect::to('contact')->with('messages', 'Thank you, your message has been received');
When form is submitted, it successfully sends two emails. One to the website admin, the other to the person who submitted the form.
Problem being, once redirected I expect to see the flash data which I don't. I am currently using var_dump(Session::all()) to show data.
Saying this, when I remove one or both Mail functions, the flash data displays correct on submit.
Furthermore, the above script is working on a local build but not on my development server.
I am very stuck and have been looking for a solution for a few hours, any insight will be much appreciated!

Related

Preview Laravel Mail before sending

I want to edit my mail and change everything, if I want, as shown here.
Ive imported my file and created a test route to view the page:
use Illuminate\Mail\Markdown;
Route::get('/mail/html', function () {
$markdown = new Markdown(view(), config('mail.markdown'));
return $markdown->render('vendor.mail.html.message'); // or ..markdown.message
});
However, Im having variable errors for #slot. How to view my change/see what the mail looks like before sending? Another package for that?
Thanks
To preview your email in browser please add below code to route
Route::get('preview-notification', function () {
$markdown = new \Illuminate\Mail\Markdown(view(), config('mail.markdown'));
$data = "Your data to be use in blade file";
return $markdown->render("path-of-your-templete-blade-file", $data]);
});
and you will be access your templete using
http://your-application-url/preview-notification
This is the recommended way by the Laravel community
kunal has a nice quick solution and that's how I used to do it. But now I use mailtrap.io to test emails because it allows you to replicate the whole process of sending an email.
Create a (free) account with mailtrap.io.
Add your mailtrap username and password in .env file.
By the way, Laravel is already configured to use mailtrap by default, so it is their recommended way to test emails.
Watch how Jeffrey Ways does it in his lesson:
Laravel 5.4 From Scratch: Sending Email
https://laracasts.com/series/laravel-from-scratch-2017/episodes/26
If you want to test in locally. You can put echo command in blade file at end and put die; this way you can test.Suppose you have test-email.blade.php
test-email.blade.php // file name
This is tets mail
<?php echo "test"; die; ?>
Hope it helps!

payumoney payment gateway integration

I want to integrate payumoney with laravel 5.1. I have kept the form in blade . Upon submitting the form I get this error:
method not found
then I tried to put the whole form for payment gateway (payu) in controller. It is still not working. Actually laravel unable to submit form to this url - test.payu.in.
I also used this:
$request = \Illuminate\Http\Request::create('http://localhost/mypro/payu/', 'POST', ['param1' => 'value1', 'param2' => 'value2']);
not working
Please help me solving this.
You might like to use a package for PayU Money. Here is a link it is pretty easy to use.
PayU Package.
Here you don't have to do anything.
Just register 2 route one for request and one for response.
Then you have to do the following.
// Frirst:
return Payment::make($data, function($then) {
$then->redirectTo('your/response/url');
});
// Second:
$payment = Payment::capture();
// And you have the payment here.
It is that simple.
Hope it helps.

Laravel 5.1 session not saving

My session driver is memcached.
When I fire an event and broadcast event in redis, the flash messages are not saving, but If I don't fire an event it works just fine.
I'm on Laravel 5.1.
Please help me.
BROADCAST_DRIVER=redis
CACHE_DRIVER=memcached
SESSION_DRIVER=memcached
my code look like this
if ($isEmployee)
{
event(new AccountUpdated($data));
}
Session::flash('notification', 'Account has been updated.');
return redirect()->back();
I'm using socket.io for the event and works fine
but the flash message are not saving.
If I don't fire the event the flash message are working fine.
i haven't used socket.io and my guess is data stored in the session using flash method will only be available during the subsequent HTTP request, and then will be deleted. so when you broad cast which is a request(i believe) then the flash variable gets deleted and in next redirect.
try with method for any luck
return Redirect::to('user/login')->with('message', 'Login Failed');
If you need to keep your flash data around for even more requests, you may use the reflash method, which will keep all of the flash data around for an additional request. If you only need to keep specific flash data around, you may use the keep method:
$request->session()->reflash();
reference:http://laravel.com/docs/5.1/session#flash-data

does this codeigniter code do a redirect or return html

I was looking at the example http://ellislab.com/codeigniter%20/user-guide/libraries/form_validation.html#validationrules (trying to learn codeigniter) and saw this code
$this->load->view('myform');
My question is does this cause the server to send a redirect back to the user? or does this return the user html code?
ie. I am looking to be completely REST based where a post should always redirect and never should return html(plus returning html on post screws up browsers and we have noticed the playframework model of post -> redirect -> get to work 100% of the time with browser back buttons and behaving the way a user would expect and want to keep that in place)
If the above does not redirect, anyone know of an example with validation failing that does a redirect and then displays the errors.
thanks,
Dean
$this->load->view('myform'); is a function that parse the html resource and output to the browser.
there is a redirect function in url_helper can do that.
But i just imply my function.
redirect is showing a message then redirect.
jump is jumping without a message.
message is showing a note message.
public function redirect($url,$message,$time=3){
$this->template->display('common/redirect',array('url'=>$url,'message'=>$message,'time'=>$time),$this->theme,$this->thcolor,false,0);
}
public function jump($url){
$this->template->content_display("<html><head><meta http-equiv='refresh' content='0;url={$url}'></head><body></body></html>");
}
public function message($heading,$message){
$this->template->display('common/message',array('heading'=>$heading,'message'=>$message),$this->theme,$this->thcolor,false,0);
}
It loads HTML . As a general advice I would stay away from CI. It has tons of security bugs and it's not suited for your purpose. Try laravel or better rails

CodeIgniter Email not being received

I currently have a contact form on my website which sends off an email notification upon submission. It is working perfectly on my end and even when I send it externally to friends as a test they are receiving it.
My client however, who is in France, can't seem to receive this email at all and I have no idea why. Is there anything I need to do to ensure that they receive it? I thought it was something on their end but they're absolutely adamant that it's not and that it's a problem with my code. I have tried different email addresses for them with different domains and still no luck!
$this->load->library('parser');
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$this->load->library('email');
$data = array(
'first_name' => $this->input->post('first_name'),
'last_name' => $this->input->post('last_name'),
'email' => $this->input->post('email'),
'phone' => $this->input->post('phone'),
'message' => $this->input->post('message')
);
$body = $this->parser->parse('html_email', $data, true);
$this->email->from('test#test.com', 'Duparc');
$this->email->to('test#test.com');
$this->email->subject('Test Email');
$this->email->message($body);
$this->email->send();
In my opinion the problem does not originate from CodeIgniter. Assuming the mail did not went into a spam box, your customer's provider is probably dismissing your message for some other reason. One reason I can immediately think of is that you are probably trying to send a message from a domain (e.g. test.com) you're not allowed from. My advise is starting to try sending an email with another tool to your french customer (any sendmail or postfix client tool) and to see if he do receive it.
If that succeeds, then the problem probably comes from your forged email (therefore try using a valid domain name). Sometimes removing it completely will work too (it might then be replaced by the external IP).
If not, then the problem comes from your web server's config. I had this problem using postfix where I had to explicitly set the "General Options" > "What domain to use in outbound mail" configuration option to my domain name in order to be accepted by a capricious server which silently dismissed our mail.
If nothing is working, you might also use another mail server which might luckily fix the issue. Here is the code I used to force CodeIgniter using sendmail instead:
$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$this->email->initialize($config);

Resources