Add BCC to all emails in Magento - email

As in the title, I need to have a copy of all emails through Magento to a specific email address.
In which file I've to work and how can I obtain the result?
Thanks in advance

System > Configuration > Sales > Sales E-Mails. Navigate to each email type then Send Order Email Copy To and set the Method to BCC via Send Order Email Copy Method.
Or
$mailTemplate->setTemplateSubject($mailSubject)->addBCC('youremail#add.ress')
->s‌​endTransactional($templateId, $sender, $email, $cus_name, $data, $storeId);

Unlike addBcc,addCc is not defined in class Mage_Core_Model_Email_Template. You can either extend Mage_Core_Model_Email_Template class to include addCc method in a similar fashion as addBcc, or modify your code like this:
// Send Transactional Email
try{
$mail = Mage::getModel('core/email_template');
$mail->getMail()->addCc('abc#gmail.com');
$mail->addBcc('abcd2#gmail.com')
->sendTransactional($templateId, $sender, $recepientEmail, $recepientName, $vars, $storeId);
}
catch(Exception $e){
print_r($e);
}

Related

how to send email with a HTML view/template using Mailgun on Lumen

I setup email notifications on my Lumen project using Mailgun.
I have a trait for sending emails, see the code below;
trait SendEmailTrait {
public function sendEmail($to, $subject, $body) {
Mail::raw($body, function ($message) use ($to, $subject, $body) {
$message->to($to)
->subject($subject);
});
if (Mail::flushMacros()) {
return 'Sorry! Please try again latter :(';
} else {
return 'Great! eMail successfully sent ;)';
}
}
}
and then I use the trait as follows;
$this->sendEmail($user->email, 'Welcome to ...', 'Your registration was successful');
I want to send the emails using an HTML template, does mailgun support that? and if it's possible, how can I get it done?

Get a notification from SendGrid when an email is open

SendGrid can track when the emails are opened:
How to get a notification (via email) when emails are opened, for which the recipient is different to myself#gmail.com? (I don't want to receive a notification when I open my own emails sent to myself as BCC).
Do I need to use the SendgridAPI? How? Can I ask Sendgrid to send a notification? (To my server, who will send the notification? To something else?)
The solution is to go in Dashboard > Settings > Mail settings > Event notification.
Then here is a possible eventlistener.php:
<?php
$postdata = json_decode(file_get_contents("php://input"));
foreach ($postdata as $event)
{
if (($event->event === 'open') && ($event->email !== 'myself#gmail.com'))
{
mail('myself#gmail.com', 'Mail to ' . $event->email . ' opened', 'Opened.', "From: myself#gmail.com");
}
}
?>

Bulk email in cakephp using sendgrid

I am using cakePHP to send smtp email with sendgrid. I would like to be able to execute a single send() to multiple recipients and allow sendgrid to use the vars to replace -name- with the names from a array.
In my cakephp controller method I am testing:
protected function fwtEmail() {
$config = 'sendGrid';
$subject = "test";
$Email = new CakeEmail('sendGrid');
$names = array('user#domain.com'=>'John','user2#domain' =>'Paul');
$Email->To($names);
$vars = array('Paul', 'John');
$Email->viewVars(array('name' => $vars));
$Email->from( array('admin#testdomain.com' => 'Jim') );
$Email->subject($subject);
$template = 'bulk';
$Email->template($template, 'default');
$Email->sendAs = 'both';
return $Email->send();
}
Here is a post on the SendGrid blog that does what you describe.
edit: apologies, this appears not to work in the latest cakephp. I'm trying to find a solution for you.

how do i send an email through joomla

I have a system so folks can register for a class through my Joomla site (I believe it's 3.0). But from there, I would like to send folks an email filling variables from the registration. So something like:
Dear (name), thank you for registering for (class).
This is to remind you your class is tomorrow, (date), at (place).
I believe for the registration, the system uses authorize.net
How can I accomplish this?
Thanks for the help!!
You can use JFactory:getMailer like suggested in the following post. I'm copying here his code example (modified it a bit):
$subject = "Here is the subject of your message.";
$body = "Here is the body of your message.";
$user = JFactory::getUser();
$to = $user->email;
$from = array("me#mydomain.com", "Brian Edgerton");
# Invoke JMail Class
$mailer = JFactory::getMailer();
# Set sender array so that my name will show up neatly in your inbox
$mailer->setSender($from);
# Add a recipient -- this can be a single address (string) or an array of addresses
$mailer->addRecipient($to);
$mailer->setSubject($subject);
$mailer->setBody($body);
# If you would like to send as HTML, include this line; otherwise, leave it out
$mailer->isHTML();
# Send once you have set all of your options
$mailer->send();
That's all there is to it for sending a simple email. If you would like to add carbon copy recipients, include the following before sending the email:
# Add a blind carbon copy
$mailer->addBCC("blindcopy#yourdomain.com");
Another alternative is using JMail::sendMail: http://docs.joomla.org/API17:JMail::sendMail
Fetch the Mail Object:
`$mailer = JFactory::getMailer();`
Set a Sender
$user = JFactory::getUser();
$recipient = $user->email;
$mailer->addRecipient($recipient);
$mailer->setSender($sender);
Recipient
$user = JFactory::getUser();
$recipient = $user->email;
$mailer->addRecipient($recipient);
Create the Mail
$body = 'Body Text';
$mailer->isHtml(true);
$mailer->Encoding = 'base64';
$mailer->setBody($body);
Sending the Mail
$send = $mailer->Send();
if ( $send !== true ) {
echo 'Error sending email: ';
} else {
echo 'Mail sent';
}
https://docs.joomla.org/Sending_email_from_extensions

How to send email message to two email id Address in zend Mail

Hi I am new in zend framework.
I have 2 email id's and i want to send message to 2 mail ids in zend mail
this is my code
$to1='abcd#gmail.com'
$to2='xyz#gmail.com'
$mailObj = new Zend_Mail()
$mailObj->setSubject($subject)
mailObj->setBodyHtml($message)
$mailObj->addTo($to1, $name='test')
$mailObj->setFrom($from, $name = null)
$mailObj->send()
You have to add Recipients using array like below
$recipients = array('abcd#gmail.com','xyz#gmail.com')
$message = new Zend_Mail();
$message->setFrom('fake#email.com', 'My Fake Mailing List')
->setSubject($subject)
->setBodyText($body);
foreach($recipients as $each_recipient){
$message->addTo($each_recipient);
}
$message->send();
for detail documentation you can check Zend_Mail - adding recipients
let me know if i can help you more.
You can define receiver as an array, for example:
$mailObj->addTo(array('address1#example.com', 'address2#example.com'), 'test');