i'm new to laravel, i need to send multiple emails using laravel it is possible ?
i'm try :-
Mail::send('mail.Vehicle_request', compact('result_email'), function($message) use ($result_email) {
$message->to($result_email->email, $result_email->first_name . ' ' . $result_email->last_name)
->subject('Vehicle Request');
});
Thank You
You can use mailable and send mail to multiple recipients adding them in the loop. You can refer more in the documentation link.
https://laravel.com/docs/8.x/mail
foreach (['taylor#example.com', 'dries#example.com'] as $recipient) {
Mail::to($recipient)->send(new OrderShipped($order));
}
Related
I need someone to tell me how to send notifications from laravel to expo, I searched in the internet I did not understand, and I don't know how to send a notification for push token generated by expo
The easies way I found was to just use the post API provided by expo
I just created a service class
<?php
namespace App\Http\Services;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
class ExpoService
{
public function sendPushNotification($recipients,$title,$body){
$response = Http::post("https://exp.host/--/api/v2/push/send",[
"to" => $recipients ,
"title"=>$title,
"body"=> $body
])->json();
Log::info($response);
}
}
$recipients is an array of tokens
I've an application that sends a mail to list of emails after submit the form. For this I'm using queue jobs to send mail to that list in the background. I'm using SMTP for this with mailtrap. I'm new to this queue jobs functionality.
this is my controller code to dispatch queue:
public function sendMail(Request $request)
{
$lists = List::where('list_id',$request->list_id)->pluck('email')->toArray();
$jobs = (new SendEmailToList($lists));
$this->dispatch($jobs);
return 'success';
}
And this is my job functionality in queue :
public function handle()
{
$lists = $this->lists;
Mail::send('email.test', array('email' => 'Sample'), function ($message) use ($lists) {
$message->to($lists);
});
}
I've a program file in the supervisor of my Linux system to queue:listen.
I've done all things but still it's not sending mail to all the list of emails. I've referred many of documentations but still same issue, all the documents given that to implement a QueueManager.
You should probably call Mail::queue or Mail::later instead of Mail::send.
Please refer to Mail documentation in case you've been missing something else.
I want to send an email using codeigniter library to my newsletter members and I want to mention each members' Email address in email's content. For doing that, I used foreach loop to send the email one by one. The problem is that the code sends email to just one member ( the first member ) of my newsletter. I've checked my code which gets members from the database and it printed out all the members.
This is my model:
function send_news()
{
$subscribers = $this->get_subscriber_data();
foreach($subscribers as $subscriber)
{
$this->load->helper('typography');
//Format email content using an HTML file
$data['news_Title'] = $this->input->post('news_Title');
$HTML_Message = $this->load->view('admin/includes/newsletter_html_format', $data, true);
$config['mailtype'] = 'html';
$this->email->initialize($config);
$this->email->from('newsletter#site.com', 'newsletter of site.com');
$this->email->to($subscriber->subscriber_Email);
$this->email->subject('newsletter of site.com');
$this->email->message($HTML_Message);
return $this->email->send();
}
}
and this is how I'm getting subscribers list:
function get_subscriber_data($options = array())
{
$query = $this->db->get('mg_newsletter');
if(isset($options['subscriber_Id']))
return $query->row(0);
return $query->result();
}
when I try to echo $subscriber->subscriber_Email it prints all the emails in the database one after another. but it does not send email to all of them. What am I doing wrong?!
use
$this->email->clear()
As codeignitor says:
Initializes all the email variables to an empty state. This function is intended for use if you run the email sending function in a loop, permitting the data to be reset between cycles.
foreach ($list as $name => $address)
{
$this->email->clear();
$this->email->to($address);
$this->email->from('your#example.com');
$this->email->subject('Here is your info '.$name);
$this->email->message('Hi '.$name.' Here is the info you requested.');
$this->email->send();
}
If you set the parameter to TRUE any attachments will be cleared as well. Then let us know
You are "return" -ing inside your loop, which exits the function.
Just send
You can keep the loading helper file and email configuration outside the loop and then remove the return from for loop, it will send to all subscribers one by one and then after loop finishes you can do the return statement.
I am SwiftMailer with Laravel 4 to send emails.
It works fine, but it takes about 5 seconds to send a single mail.
It is possible somehow to speed up the process?
Thank you!
EDIT: I Would like to use the queue in this function:
public function send()
{
$self = $this;
return \Mail::queue($this->view, $this->data, function($message) use($self)
{
$message->to($self->email)->subject($self->subject);
});
}
I have created an account in iron.io and inserted into queue.php the project_id and the token. What i have to insert in this case as queue-name?
Use Queues: http://laravel.com/docs/queues
It's pretty easy to setup IronMQ in Laravel: http://iron.io/
This is a screencast from Taylor showing it: http://vimeo.com/64703617
I want to send custom mail through smtp.For which I installed http://www.magentocommerce.com/magento-connect/aschroder-com-smtp-pro-email-free-and-easy-magento-emailing-for-smtp-gmail-or-google-apps-email.html.
Which works properly for every mail provided by magento as default.
Now since the admin is having mail Id of google apps , my custom mail is not received by admin.So for this reason I want to Integrate my controller with the sending mail function of ashrodder extension.
My Controller code:
$frm = 'mail#domainname.com';
$to = 'admin#domainname.com';
$subject = "UPDATE";
$mail = new Zend_Mail('utf-8');
$mail->setBodyHtml($message)
->setFrom($frm, 'Admin')
->addTo($to, 'Site Admin')
->setSubject($subject);
try {
$mail->send();
Mage::getSingleton('core/session')->addSuccess('Mail sent successfully.');
}
catch(Exception $e) {
Mage::getSingleton('core/session')->addError('Unable to send email.');
}
My question is simple : How should I pass [to,from,body] variable to any other model/controller ?
Please Help .Thanks in Advance
I think overriding the extensions controller would be the best solution.Check this link How to extend a controller