Error Sending Template Data
forgot password? This is an archived forum and may no longer be relevant. The active forums are here. Advanced Search $data Error Sending Email Template razerone Posted: 12 November 2013 03:21 AM Joined: 2013-09-2484 posts Hi I have a small issue with my $data on the $mesg = $this->load->view(‘information/eview', $data, true); It only works sending the template if have $data. But on the confirmation sent page it show up as A PHP Error was encountered Severity: Notice Message: Undefined variable: data Filename: controllers/contact.php Line Number: 47 this->config->load('email'); $config = array( 'charset'=>'utf-8', 'wordwrap'=> TRUE, 'mailtype' => 'html' ); $this->email->initialize($config); $this->email->from($this->input->post('email'), $this->input->post('name')); $this->email->to($this->config->item('smtp_user')); $this->email->subject('subject'); $mesg = $this->load->view('information/eview', $data, true); // line 47 $this->email->message($mesg); razerone Posted: 12 November 2013 04:26 AM [ # 1 ] Joined: 2013-09-2484 posts I found out my self the best way to get a email template HTML. $this->config->load('email'); $config = array( 'charset'=>'utf-8', 'wordwrap'=> TRUE, 'mailtype' => 'html' ); $this->email->initialize($config); $name = $this->input->post('name'); $email = $this->input->post('email'); $subject = $this->input->post('subject'); $message = $this->input->post('message'); $this->email->from($this->input->post('email'), $this->input->post('name')); $this->email->to($this->config->item('smtp_user')); $this->email->subject($subject); $emailnoticetemplate = $this->load->view('information/eview', '', TRUE); $this->email->message($emailnoticetemplate); ©2002–2016, EllisLab, Inc.Privacy Policy, Terms of Service built on ExpressionEnginereturn to the top twitter PixelBuzz eNews
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign https://ellislab.com/forums/archive/viewreply/1060704/ up Sendgrid: Send email with template up vote 2 down vote favorite 1 I am trying to send emails with SendGrid and am trying to have multiple templates for different cases. My function looks like this: var file = "welcome.html" sendgrid.send({ to: to, from: from, subject: subject, data: { //template vars go here email: to, confirmLink: confirmLink }, template: "./" + file http://stackoverflow.com/questions/28774276/sendgrid-send-email-with-template }, function(err, json) { if (err) { return console.error(err); } console.log(json); }); But when I am sending the email I get [Error: Missing email body] Would there be any way to attach html templates, since I don't want to have hard-coded strings with html content? Edit Reading and converting the file into a string works, but I am unsure how to pass in dynamic variables into the template.. Any suggestions? email sendgrid share|improve this question edited Feb 27 '15 at 22:57 asked Feb 27 '15 at 21:07 Claudiu S 69321325 You should really consider using a third-party templating service, such as sendwithus.com or even customer.io. Their API makes it much easier to pass dynamic variables into templates. Bonus - you don't have to parse/render HTML yourself. –bvanvugt Feb 28 '15 at 2:01 I found that sendgrid do have developed a Templating engine. I have also dug into the source and found a solution. I will post it. –Claudiu S Mar 1 '15 at 12:30 Awesome, thanks for following up! –bvanvugt Mar 3 '15 at 1:36 add a comment| 2
Gherkin Git Go Groovy Haml Handlebars Haskell HTML HTTP Ini iOS Jade Java Javascript jQuery JSON Julia Keyman LaTeX Linux Less LOLCODE Makefile Markdown MATLAB MySQL NASM Node.js NSIS Objective-C https://codedump.io/share/wlrWL4zLEhUl/1/error-when-sending-data-to-email-template-in-laravel-51 Pascal Perl PHP PHP Extras PowerShell Python R React JSX reST (reStructuredText) Rip Ruby Rust SAS Sass (Sass) Sass (Scss) Scala Scheme Smalltalk Smarty SQL Stylus Swift Twig TypeScript Vb.net VHDL Wiki markup YAML Other Search Pankaj Garg - 9 months ago 83x PHP Question Error when sending data to Email Template in Laravel 5.1 below is my html in Blade
Hi {!! $Data->ContractorUserName !!},
Thanks
below is data that is being passed to Email function Params. $data = array(
"ContractorUserName" => $Bid->WhoPlacedBid->UserName
);
Below is the code that sends email \Mail::send('Project.Emails.Award', array('Data', $data), function($message)
{
$message
->to('EmailAddress', 'EmailAddress')
->subject('hi');
});
Error Details Undefined variable: Data Please suggest if I am missing something ? Anonymous Answer Email {} Share When you pass data in to the email through the Mail::send process, the array isn't actually passed in as a whole - just the individual variables. Try doing it like this: $data = array( "ContractorUserName" => $Bid->WhoPlacedBid->UserName ); Mail::send('Project.Emails.Award', $data, function($message) { $message ->to('EmailAddress', 'EmailAddress') ->subject('hi'); }); And then access it in the view like so: