On my site sales order email is not working. when user registered than mail goes to the user but sale order email is not working. in email's template file template.php on line no 407 when I have change the if condition into
if (!($this->hasQueue() && $this->getQueue() instanceof Mage_Core_Model_Email_Queue)) { than sales order email working and new user registration email stop working.
in template.php code is :
if ($this->hasQueue() && $this->getQueue() instanceof Mage_Core_Model_Email_Queue) {
/** #var $emailQueue Mage_Core_Model_Email_Queue */
$emailQueue = $this->getQueue();
$emailQueue->setMessageBody($text);
$emailQueue->setMessageParameters(array(
'subject' => $subject,
'return_path_email' => $returnPathEmail,
'is_plain' => $this->isPlain(),
'from_email' => $this->getSenderEmail(),
'from_name' => $this->getSenderName(),
'reply_to' => $this->getMail()->getReplyTo(),
'return_to' => $this->getMail()->getReturnPath(),
))
->addRecipients($emails, $names, Mage_Core_Model_Email_Queue::EMAIL_TYPE_TO)
->addRecipients($this->_bccEmails, array(), Mage_Core_Model_Email_Queue::EMAIL_TYPE_BCC);
$emailQueue->addMessageToQueue();
return true;
}
when I have changed the if condition like
if (!($this->hasQueue() && $this->getQueue() instanceof Mage_Core_Model_Email_Queue)) {
than sales order mail working but new user registration stop working.
what can I do for sales order and new user registration emails ?
Magento 1.9.x store the order email in core_email_queue table to send the mail of order. You must to set the cron job in your server.
I think it will be work for you.
I have change if condition and its working for me. I have made changes in app/code/core/Mage/Core/Model/Email/Template.php on line no 407
I have change the if condition
if ($this->hasQueue() && $this->getQueue() instanceof Mage_Core_Model_Email_Queue)
To
if (false/$this->hasQueue() && $this->getQueue() instanceof Mage_Core_Model_Email_Queue/)
Related
Well I'm setting up a database where user details would be stored using ionic as front end and lumen to make API calls. My concern is that can i send a push notification to all the people who are using my application using the email information that is in my database. Is it possible
Following is the code that i am trying to do :
public function send_notification_all(Request $request){
$this->validate($request, [
'title' => 'required|max:30|min:20',
'message' => 'required'
]);
$noti_title = $request->input('title');
$noti_body = $request->input('message');
$optionBuilder = new OptionsBuilder();
$optionBuilder->setTimeToLive(60*20);
$notificationBuilder = new PayloadNotificationBuilder($noti_title);
$notificationBuilder->setBody($noti_body)
->setSound('default');
$dataBuilder = new PayloadDataBuilder();
$dataBuilder->addData(['a_data' => 'my_data']);
$option = $optionBuilder->build();
$notification = $notificationBuilder->build();
$data = $dataBuilder->build();
$email = User::pluck('email')->toArray();
$downstreamResponse = FCM::sendTo($email, $option, $notification, $data);
$downstreamResponse->numberSuccess();
$downstreamResponse->numberFailure();
$downstreamResponse->numberModification();
if($downstreamResponse->numberSuccess() == 0 ){
return $this->errorResponse("unable to send notificaton to all",401);
}else {
return $this->successResponse(['msg' => 'message send successfully','successfull' => $downstreamResponse->numberSuccess(),'failures' => $downstreamResponse->numberFailure()]);
}
}
Just need the opinion that is it possible to do it in this way and do let me know if there is any mistake or the changes that i have to make in my code. Waiting for the Positive response and Guidance
You can't send notifications using their email addresses.
You should save in your Database the fcm_token of every user who registers. I suggest using the following package and reading the docs in it: Laravel-FCM
You should also take care of refreshing the token if the device request so.
I'm facing one problem while sending emails with SendGrid. I'm sending normal email with assigning unsubscribe ground id. And when sending email then getting two links Unsubscribe From This List and Manage Email Preferences. Now my requirement is that I want to change these link texts from
Unsubscribe From This List => Unsubscribe
Manage Email Preferences => Update Preferences
And also links are not coming in the bottom of email. I want these after footer texts.
I'm not using marketing emails. Below is the one email screen-shot which I got:-
And below is the code for sending email. I'm using Laravel for sending emails:-
public function sendMail()
{
$status = \Mail::send('emails.demo', ['name' => "testdata"], function($message)
{
$args = [
'asm_group_id' => 3169
];
$message->getHeaders()->addTextHeader('X-SMTPAPI', json_encode($args));
$message->to('test#gmail.com', 'Test User')->subject('This is a demo!');
});
}
Please suggest me if anyone have idea how can I achieve this.
Check this package. https://github.com/s-ichikawa/laravel-sendgrid-driver .
This is the correct format for the above package:
$send = \Mail::send('emails.tests.tests', compact([]),
function (Message $message) use (
$subject, $from_email, $from_name, $to_emails, $to_name ) {
$message->subject($subject)
//->attach($pathToFile)
//->to($to_emails)
->to($to_emails, $to_name)
//->cc($cc_email)
->from($from_email, $from_name)
->embedData([
'asm' => ['group_id' => 123],
],
'sendgrid/x-smtpapi');
});
if you are not using this package then
$status = Mail::send('emails.test', compact('data_var'), function($message)
{
$args = [
'asm_group_id' => 123
];
$message->from('testfrom#gmail.com','from name');
$message->getHeaders()->addTextHeader('X-SMTPAPI', json_encode($args));
$message->to('testto#gmail.com', 'Test User')
->subject('This is a demo!');
});
I have two emails that get sent out, and both are called in a similar fashion. However, there is one major difference: For one of them, the recipient of the CC gets the email, and for the other she does not. I have absolutely NO idea what might be causing this behavior, since they appear to be exactly identical otherwise.
This is the code used to create the email that DOES get the CC applied properly:
public function sendEmail($order = array(), $account = array(), $member = null) {
$email = new CakeEmail();
$email->template('order', 'default')
->helpers(array('Html'))
->viewVars(array('order' => $order, 'account' => $account, 'member' => $member))
->emailFormat('html')
->to($account['Account']['email'])
->cc('katherine#thecommunitycoop.org')
->from('general#thecommunitycoop.com')
->subject('Your order for '.$order['Sale']['sale_date'])
->send();
This is the code used to create to create the email that is NOT getting the CC:
public function pendingEmail($order = array(), $member = false, $success = true) {
$email = new CakeEmail();
$email->template('pending', 'default')
->helpers(array('Html'))
->viewVars(array('order' => $order, 'member'=>$member, 'success' => $success))
->emailFormat('html')
->to($order['Account']['email'])
->cc('katherine#thecommunitycoop.org')
->from('general#thecommunitycoop.com')
->subject('Your order for '.$order['Sale']['sale_date'])
->send();
As you can see, the cc field is identical. Both emails are getting sent to the 'to' field correctly; it is only the cc field that is not working properly on the second one. What could possibly be causing this behavior?
I've seen on a few blog articles that this is a common way to send an email in Magento, but I have for the life of me, no idea why this email isnt being sent in 1.10! This is my method:
protected function _emailCode($code, $invoice) {
$order = $invoice->getOrder();
// Transactional Email Template's ID
$templateId = 1;
// Set sender information
$senderName = Mage::getStoreConfig('trans_email/ident_support/name');
$senderEmail = Mage::getStoreConfig('trans_email/ident_support/email');
$sender = array('name' => $senderName,
'email' => $senderEmail);
// Set recepient information
$recepientEmail = $order->getCustomerEmail();
$recepientName = $order->getCustomerName();
// Get Store ID
$storeId = Mage::app()->getStore()->getId();
// Set variables that can be used in email template
$vars = array('voucherCode' => $code);
$translate = Mage::getSingleton('core/translate');
// Send Transactional Email
Mage::getModel('core/email_template')
->sendTransactional($templateId, $sender, $recepientEmail, $recepientName, $vars, $storeId);
$translate->setTranslateInline(true);
}
I should note that emails works in other parts of Magento so sendmail is working properly and all that, also all my variables here are defined correctly and not empty when going through this.
Thanks!
Are you sure that transactional email with ID=1 exist?
try setting $templateId='sales_email_order_template'
this is a default template, should fit working script.
Check exception.log also.
I want magento to send the order emails only to the admin not to the customer,
because the customer gets an email from another system.
It's possible to send an ordermail to the customer, or to the customer and admin but it seems to be impossible to send the mail only to the admin.
If someone knows how to do it I would be very thankful.
best regards nico
Good news: it's easy. Bad news: you cannot make it in interface, you can only program it.
Overload sending of emails in Mage_Sales_Model_Order->sendNewOrderEmail(), remove sending to customer from there.
thanks a lot!
I just commentet out this area, and it works.
/* $sendTo = array(
array(
'email' => $this->getCustomerEmail(),
'name' => $customerName
)
);
*/
if ($copyTo && $copyMethod == 'copy') {
foreach ($copyTo as $email) {
$sendTo[] = array(
'email' => $email,
'name' => null
);
}
}