if($validator->passes())
{
$response = Mail::send('emails.contact',$data, function($message) use($data,$carName,$num)
{
$message->from(Config::get('mail.from.address'), Config::get('mail.from.name'));
$message->to(Config::get('mail.from.address'))->subject('Enquiry '.date('Y-m-d ').'Car name: '. $carName.'count: '. $counter);;
});
is there any way to implement my $counter variable? i want to display it in the subject of the email. Thank you zaalbarxx
What is this counter counting itself ? All I see is you are trying to send an email somewhere with some $counter in the subject. You could create an event listener which would listen for mail.sent
and take some arguments you need and then increment some value in database for given e-mail. Then you would have access to this counter. Still I am not sure if this is what you are thinking about.
yup you got it but is there a way for me not to use database for the counter . for example i will build a global variable then it increments whenever there is an email send.
You mean you want to count the number of all emails sent within one particular request ? You can then listen to event like :
Event::listen('mailer.sending', function($message){ //$message is not neccessary, but you may want it
//do something to persist the counter, may be some singleton or even session
});
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community