This code is working for a single recipient but not for multiple recipients.How should I add multiple recipient into send() function in here.
//find price
$price = MDealPrice::model()->find("id=:id", array(':id' => $id));
// find deal
$deal = MDeal::model()->find("id=:id", array(':id' => $price->dealId));
//send email
app()->mailer->send($sendEmailAdd, 'orderAuthorizeEmail', array('deal' => $deal));
I tried like this also, But not worked.
//send email
app()->mailer->send(array('email1#domain.com','email2#domain.com'), 'orderAuthorizeEmail', array('deal' => $deal));
Thanks in advance!
Please try with below solution it will work
app()->mailer->send('email1#domain.com,email2#domain.com', 'orderAuthorizeEmail', array('deal' => $deal));
just add your email ids comma separated string in send function instead to pass array of email ids.
Related
i'm using Gmail API to fetch messages. if i do like this
$labelIds = ['INBOX'];
$opt_params=[
'labelIds' => $labelIds,
];
$list = $gmail->users_messages->listUsersMessages('me',$opt_params);
it will work fine. and return messages. but if i mention SENT label with INBOX then it return nothing. what am i doing wrong?
$labelIds = ['INBOX', 'SENT'];
i want to fetch emails from both inbox and sentbox in one call.
Your code lists messages that has both the INBOX and SENT labels. You can list messages that has either one with the OR operator:
$opt_params=[
'maxResults' => 50,
'q' => 'in:inbox OR in:sent',
];
$list = $gmail->users_messages->listUsersMessages('me', $opt_params);
Need Help!
Using CakePHP, I need to send the same email to two users, I referred this thing in forum, they all suggesting to declare a array of emails, via for loop could achieve it. But I want to make it simple that, don't wanna go for loop, how to add a one more email account over there. For (e.g. abc#account.com) need to send the same email
What I am doing to send an email for one user is......(Below Codes)
$emailadmin->template('learn_payment', 'default')
->to([$this->request->session()->read('Auth.User.email') => Configure::read('app_title')])
->from([Configure::read('support_email') => Configure::read('app_title')])
->subject(sprintf('You have subscribed a learning on %s', Configure::read('app_title')))
->emailFormat('both')
->send();
Thanks in Advance!
you can use two ways:
$mails = array();
foreach($users as $user)
{
$mails[] = 'email1#email1.com';
$mails[] = 'email2#email2.com';
}
$emailadmin->template('learn_payment', 'default')
->to($mails)
->from([Configure::read('support_email') => Configure::read('app_title')])
->subject(sprintf('You have subscribed a learning on %s', Configure::read('app_title')))
->emailFormat('both')
->send();
Or this way:
$emailadmin = new CakeEmail();
foreach($users as $user) {
$emailadmin->addTo($user['User']['email']);
}
$emailadmin->template('learn_payment', 'default')
->from([Configure::read('support_email') => Configure::read('app_title')])
->subject(sprintf('You have subscribed a learning on %s', Configure::read('app_title')))
->emailFormat('both')
->send();
below is my code to send a mail to multiple users.
$email_id = User::select('email_id')->get()->pluck('email_id');
Mail::send('mail', [], function($message) use ($email_id)
{
$message->to($email_id)->subject('Welcome!!!');
});
I m getting the values in $email_id as
["xyz#abc.com","abc#abc.com","qwerty#abc.com"]
With this I get error of
Illegal Offset Type.
But when I write explicitly as
$email_id = ["xyz#abc.com","abc#abc.com","qwerty#abc.com"];
then I am able to send mail to multiple users.
Why is it not working for
$email_id= User::select('email_id')->get()->pluck('email_id');
and is working fine for
$email_id = ["xyz#abc.com","abc#abc.com","qwerty#abc.com"];
Any help would be grateful.
If we want to send only one email at a time. then we can use this code
$email_id = User::select('email_id')->get()->pluck('email_id');
Mail::send('test', array('user' => $email_id) , function ($message) {
$message->from('from#example.com'), 'From Example Name');
$message->to('xyz#gmail.com')->subject('Welcome!!!');
})
If we want to send an email to multiple users , then we can use this code
$email_id = User::select('email')->get()->pluck('email')->toArray();
Mail::send('test', array('user' => $email_id) , function ($message) use
($email_id) { $message->from('from#example.com'), 'From Example Name');
$message->to($email_id)->subject('Welcome!!!');
});
Simply append
->toArray()
function to the code.
$email_id= User::select('email_id')->get()->pluck('email_id')->toArray();
Note: sending mails this way may create bottleneck on the server and eventually force all mails to be delivered to spam/junk folder (if it ever gets delivered). To avoid this, write a function that will queue all mails. Refer to https://laravel.com/docs/5.1/mail#queueing-mail for better clarification.
I would like to use a form to send a verification email though mailgun to users when they sign up for a service. I have a form collecting the required info for the email but need to put it into the email. The problem is the way the email is formatted and I do not know how to print the data.
Here is my action:
<?php
require 'vendor/autoload.php';
use Mailgun\Mailgun;
$mgClient = new Mailgun('MY-API-KEY');
$domain = "https://api.mailgun.net/v3/MY-DOMAIN";
$result = $mgClient->sendMessage($domain, array(
'from' => 'Verifier <MY-ADDRESS>',
'to' => '<?php print_r(GET_$[email]) ?>, second-address#email.com',
'subject' => 'Verifcation & Instructions',
'text' => 'Dear print_r(GET_$[username]),
Thank you for requesting a service for print_r(GET_$[url]).
To make sure this was you, please click here and verify ...'
));
?>
I know the send is working because of the second address I have set up.
Thanks for any help!
Here is a possible solution as given to me by Mailgun Support:
http://blog.mailgun.com/double-opt-in-with-php-mailgun/
I am working on Yii and I need to send a confirmation email one sign up. The content shows the email as abc%40#example.com
the email is directly called from the database and added to the mail function
I am not sure how this can be fixed
$activation_url = $this->createAbsoluteUrl('/user/activation/activation',array("activkey" => $registerform->activkey, "email" => $registerform->email));
the above code is the sample
Any help is appreciated
Apologies
the result is shown like this abc%40example.com and not abc%40#example.com
Try this:
$activation_url = $this->createAbsoluteUrl('/user/activation/activation',array("activkey" => $registerform->activkey, "email" => urldecode($registerform->email)));