This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hello, I am trying to send an email containing form data. The problem is, I can't seem to access the form data with the Mail::send()
method.
public static function sendNotification($vars)
{
Mail::send('acme.blog::mail.message', $vars, function($message) {
$message->to($vars['emails']);
$message->from('mail@compuflexcorp.com', 'Compuflex Mail');
$message->subject($vars['post']['subject']);
$message->replyTo($vars['post']['email']);
});
}
As you can see, I created a method called sendNotification()
which is passing $vars
from one of my plugins. I have already tested it, and I can access $vars
from within my sendNotification()
method, but I cannot seem to access inside of my Mail::send()
method?
I keep getting an error:
"Undefined variable: vars" on line 5 of C:***\sendNotification.php
Line 5:
$message->to($vars['emails']);
I have no idea why? It really doesn't make any sense to me...
Any help would be greatly appreciated?
Last updated
I found a fix on StackOverflow
class SendMail {
public static function sendNotification($post, $emails)
{
Mail::send('acme.blog::mail.message', $post, function($message) use ($post, $emails) {
$message->to($emails);
$message->from('mail@compuflexcorp.com', 'Compuflex Mail');
$message->subject($post['subject']);
$message->replyTo($post['email']);
});
}
}
1-2 of 2