Laravel 5 - Sending notification via Mail shows HTML source instead of HTML - laravel

I'm sending a user - registered confirmation link email after signup.
When i open that mail with my desktop client, all shows very well. When i open that mail with my Android phone client called "Mail" (version 10) it shows the HTML tags and every line of HTML source code instead of rendered HTML.
What am i doing wrong? This is the toMail method from the notification:
public function toMail() {
$subject = trans('mail.registration_confirmation');
return (new MailMessage)
->subject($subject)
->greeting($this->registeredUser->greeting())
->line(trans('app.thank_you_for_registering', ['app' => settings('app_name')]))
->line(trans('app.confirm_email_on_link_below'))
->action(trans('app.confirm_email'), route('register.confirm-email', $this->token))
->line(trans('app.confirm_email_call_to_action'))
->line("Just another line");
}

Related

Sending html content as mail body laravel mail sending application

My controller is
public function basic_email() {
$data = array('name'=>"Virat Gandhi",'roll'=>"123");
Mail::send(['text'=>'mail'], $data, function($message) {
$message->to('xyz#gmail.com', 'Basil Baby')->subject
('Laravel Basic Testing Mail');
$message->from('abc#yahoo.com','Virat Gandhi');
});
echo "Basic Email Sent. Check your inbox.";
}
My blade is
Hi, {{ $name }}
your roll number is {{$roll}}
please click on the link to verify your account
Mail is being received. but the mail body is displaying html content as such. How to make verify you account a html link in mail body
Change your key text to html in your send function.
text key send data as a plain text
Mail::send( ['html' => 'mail']...
Also change {{}} to {!! !!}
Reference:
Laravel -> Mail
If you are trying to verify registered users, I would suggest you to use Laravel's build-in verification system.
You can follow the link:
Laravel email verification

send pusher notification to specific user - Laravel

In my laravel app, I want to send a notification to a specific user using Pusher.
I put this code in my method :
$pusher = App::make('pusher');
$pusher->trigger( 'notification-channel',
'notification-event',
array('text' => 'this is a notification'));
return view('home');
and put this in home.blade.php :
<script src="//js.pusher.com/3.0/pusher.min.js"></script>
<script>
var pusher = new Pusher("{{env("PUSHER_KEY")}}");
var channel = pusher.subscribe('notification-channel');
channel.bind('notification-event', function(data) {
alert(data.text);
});
but this makes notification to appear to any user.
This also has another problem that the user should be only on the home page to receive the notification!
So, what should I do to send a notification to a specific user and make the user receive it from any page ??
To make the user receive it from any page, put your Pusher code in your layout.blade.php if you have any. Or any other file that all pages will extends.
To make it go to a specific user, you can use the user id by appending it to the channel like
'notification-channel:' . $user->id
So in your layout file you listen to that channel
var user = <?php echo $user ; ?>;
var channel = pusher.subscribe('notification-channel:' + user.id);
Although only user with that easy might receive the notification, your notification remains public. Meaning anyone can manipulate their id and receive someone else notifications. If you want private notifications, you can follow instructions here: https://laravel.com/docs/5.4/broadcasting#authorizing-channels

send a mail to particular user while clicking on the button from view page in codeigniter

i have one view page called vendor view candidates page..in that page i display all the candidates details from database and i have user_id in that view page..and i gave button called release information..so when user click on the button the page will redirect to edit_candidates page with that particular candidate_id..and they will allow to insert email and phone number..
After they insert email and mobile number and then submit..i want to send mail to particular user_id..
This is my button:(edit candidates page)
<td>Release Contact Info</td>
Controller:
public function edit_candidates($id)
{
$data['editdata']=$this->CandidateModel->candidate($id);
if($this->input->post())
{
$this->CandidateModel->update_candidate($this->input->post(),$id);
redirect(base_url('index.php/Candidate/vendor_view_candidates'));
}
$this->load->view('Candidates/edit_candidate',$data);
}
Can anyone help me...i tried a lot..but i didn't get any idea on how to do this..
Thanks in advance..
Use the following code to fix your issue
public function edit_candidates($id)
{
$data['editdata']=$this->CandidateModel->candidate($id);
if($this->input->post('update_form'))
{
$userEmail = $this->CandidateModel->get_userinfo($data['editdata']->user_id);
//Pass this $userEmail into mail function it will send email
$this->CandidateModel->update_candidate($this->input->post(),$id);
redirect('index.php/Candidate/vendor_view_candidates','refresh');
}
else
{
$this->load->view('Candidates/edit_candidate',$data);
}
}
Let me know if it not fix your issue

Laravel 5: Sending email with attached .pdf file generated from dynamic page

I have a job website. Job seeker users can register and build their profile (online resume), and it is used for one click application.
When job seekers logged in and click "Apply Now" button to any job, I want Laravel to send an email attached with .PDF resume (generated from their online resume building page) to employer's inbox.
Note: I do not want to send their uploaded resume (.pdf/.doc) to employer's inbox because I want to promote my website's branding / resume template.
Please tell me how to achieve this. If any source code provided, I would appreciated.
thank you.
You can use a html to pdf converter (something like http://github.com/barryvdh/laravel-dompdf). This will create the users profile in PDF format.
After the user clicked the button there will be an email sended to the employer with the attached pdf from the user.
It will look something like this:
Mail::send('emails.reminder', ['user' => $user], function ($m) use ($user) {
$m->to($user->email, $user->name)->subject('Your Reminder!');
$m->attach($pathToFile);
});
And with custom mail per email:
Mail::send('emails.reminder', ['user' => $user], function ($m) use ($user) {
$m->from('hello#app.com', 'Your Application');
$m->to($user->email, $user->name)->subject('Your Reminder!');
$m->attach($pathToFile);
});
This will create the PDF, save it to the storage directory. You can use the views for the design:
public function createCollageCron($load_id) {
$load = Loads::findOrFail($load_id);
$pdf = PDF::loadView('pdf.collage', compact('load'));
if ($pdf->save(storage_path('app/loadings/'.$load->id.'/collage.pdf'))) {
return true;
} else {
return false;
}
}
Hope this works!

codeigniter with MVC pattern

I am working on ci and when i am going to delete my data then i want to generate a confirm message box on click delete link and my code is this.
view.php
id);?>">Delete
controller.php
function delete($id)
{
$this->include_user->delete($id);
redirect(site_url('admin_controller/fetch'));
}
Model.php
function delete($id)
{
$this->db->delete("user",array('id' => $id));
}
If you want to show confirmation message that either user really want to delete, then you can use jquery confirm box plugin and when click on delete anchor then on delete show the confirm box.
e.g: in js code
jConfirm('Do you really want to delete?', 'Delete Confirmation', function(r) {
if (r == true) {
}
}
In my case I am using jquery confirm box.
And in case if you want to show success message then you can send back a flag when record is deleted to controller, then checking the flag, if successfully record is deleted then pas success message to your message controller or wise failure message.

Resources