dynambee Posted November 19, 2017 Posted November 19, 2017 @daokakao said in How to get copy sent to me of all customer order-related emails?: @dynambee If you use the postfix, you already have all needed for bcc'ing any mail and you don't need any extra efforts with php, IMHO :) And thi is one of standard features in postfix Yes, of course postfix supports BCC. What I need is a way for 30bz to tell postfix to send a BCC, and the BCC address will depend on the store that is sending the email.
DaoKakao Posted November 19, 2017 Posted November 19, 2017 @dynambee said in How to get copy sent to me of all customer order-related emails?: Google charges $5 per month per email address. I just mensioned google as example. I do not use its services this way. Our local service offers everything for free, up to 1000 accounts on their infrastructure+DKIM+antivirus and antispam. So. i'm sorry, it is difficult for me to understand, that such services aren't accessible for eveyone. drawbacks however and that includes the outbound mail spam issue. This is more organizational issues. I had never faced such issues even when tested google's mail service. You want to say, that even SPF and DKIM won't help to relief that problem? That is not IMAP. As far as i understood this IS imap client right in the shop's admin. Anyway, i just tested again my nullmailer and found everything is ok - i have all copies of outgoing email in my admin's mailbox.
DaoKakao Posted November 19, 2017 Posted November 19, 2017 @dynambee said in How to get copy sent to me of all customer order-related emails?: What I need is a way for 30bz to tell postfix to send a BCC, and the BCC address will depend on the store that is sending the email senderbccmaps = type:table and recipientbccmaps = type:table ? Won't that be enough?
dynambee Posted November 19, 2017 Posted November 19, 2017 @daokakao said in How to get copy sent to me of all customer order-related emails?: senderbccmaps = type:table and recipientbccmaps = type:table ? Won’t that be enough? All of our outbound emails (automated, from the website, and human sent) go from [email protected]. This way customers can reply to any message and reach a real person. The only messages that need to be BCC'd are the ones that come from the website as they are the only ones that we don't get a copy of in our sent items folders.
DaoKakao Posted November 19, 2017 Posted November 19, 2017 Same with me: i use same google account for webserver and for mail client. On the server it is nullmailer installed with appropriate credentials. So, TB sends mails via this google account and i can see it in my outbox on the email client
dynambee Posted November 19, 2017 Posted November 19, 2017 Gmail's SMTP server behaves in different ways to postfix. I do not wish to rely in Google's mail services any longer, both for the problems of spam as well as for various other reasons. As such your suggestions about using Google are of no help whatsoever and are not relevant to this thread.
dynambee Posted November 19, 2017 Posted November 19, 2017 For now I think I have found a solution to force BCC for messages sent from 30bz. In the end I modified the Mail.php file and added the BCC address at line #247: 234 if (isset($bcc) && is_array($bcc)) { 235 foreach ($bcc as $addr) { 236 $addr = trim($addr); 237 if (!Validate::isEmail($addr)) { 238 Tools::dieOrLog(Tools::displayError('Error: invalid e-mail address'), $die); 239 240 return false; 241 } 242 $message->addBcc($addr); 243 } 244 } elseif (isset($bcc)) { 245 $message->addBcc($bcc); 246 } 247 $message->addBcc('[email protected]'); I had hoped to make the change within swiftmailer but for now this should work fine. As always, it's far from ideal to modify core files and future upgrades will no doubt overwrite Mail.php and require me to add that single line of code again. @mdekker, pretty low priority I suppose but maybe at some point the option to send a BCC could be added. Even better would be IMAP for outbound emails but that seems like it would be a lot more work than just a BCC option.
Traumflug Posted November 20, 2017 Posted November 20, 2017 @daokakao why not to bind your MX record For this to happen, a user whould have to understand that an "MX record" actually exists, what it does and how it's changed. I don't think this is the level of expertise 30bz wants to be mandatory for running a shop. There has to be an easier solution ... which doesn't stop experts from doing what you described, of course.
Traumflug Posted November 20, 2017 Posted November 20, 2017 Looking at this discussion I think there is an actual demand, so I opened an enhancement issue for this, mentioning @dynambee's (partial) solution: https://github.com/thirtybees/thirtybees/issues/397
dynambee Posted November 20, 2017 Posted November 20, 2017 @yaniv14 said in How to get copy sent to me of all customer order-related emails?: I guess it will be better to override the Send function in Mail.php to add a static bcc address. Never tested it but I think it should work, just create an override to the entire function and set a default bcc instead of null. You can probably just call the parent function and modify the bcc, but I rather check it before posting here. I still have a lot to learn about how PS/30bz overrides work and I didn't properly understand your message the first time I read it. I do now though, and I think your idea is correct. With this in mind I have created a simple override that I have tested and it is working. If anyone else would like to do the same thing, here is the override PHP code and how to use it: Code: <?php class Mail extends MailCore { public static function Send($id_lang, $template, $subject, $template_vars, $to, $to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null, $template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null, $reply_to = null) { $bcc = '[email protected]'; return parent::Send($id_lang, $template, $subject, $template_vars, $to, $to_name, $from, $from_name, $file_attachment, $mode_smtp, $template_path, $die, $id_shop, $bcc, $reply_to); } } ?> Change the email address to be where you want the BCC mails to be sent. Double check it! That address will be receiving a lot of messages so make sure you get it right. Once you have the BCC address correctly set, save the file to the /override/classes directory with the filename Mail.php. After saving the file visit the /cache directory and delete the file class_index.php. This file must be deleted so 30bz will recognize the override. If you change the override or remove it then this the class_index.php must be deleted each time. 30bz will rebuild it automatically. Now do something that would generate an email (anything except the "test message" should work) and you should receive a BCC of that email at the address you have specified. Edit: Spelling & grammar.
dynambee Posted November 20, 2017 Posted November 20, 2017 @traumflug said in How to get copy sent to me of all customer order-related emails?: Looking at this discussion I think there is an actual demand, so I opened an enhancement issue for this, mentioning @dynambee's (partial) solution: https://github.com/thirtybees/thirtybees/issues/397 I think it's a useful way to keep tabs on the emails being sent by the site and to make sure the emails are properly formatted and contain the expected information. It would be easy to upgrade or change something and not realize the emails were going out borked for quite some time. The people running the store don't usually see those messages. To keep things simple and avoid the potential for BCCs being sent to a wildly incorrect address perhaps if the "BCC option" is turned on then BCC messages should be sent to the $from address?
lesley Posted November 20, 2017 Posted November 20, 2017 Its not free, but another way is to use a smtp email server as well, instead of php mail. We use Mandrill a lot with our clients, that way we can see everything that goes out, and if people are opening and clicking too.
wakabayashi Posted November 20, 2017 Posted November 20, 2017 We use sendgrid for that purpose. It's free for us. I think it's a very good solution if your store is small.
DaoKakao Posted November 20, 2017 Posted November 20, 2017 @lesley said in How to get copy sent to me of all customer order-related emails?: Its not free, but another way is to use a smtp email server as well, instead of php mail. We use Mandrill a lot with our clients, that way we can see everything that goes out, and if people are opening and clicking too. As far as i know, php mail() doesn't exclude need of MTA use because of use 'sendmail' command. Also it could be a headache on the Win* platform because it functioning different on it Taking in account all said above, it seems like an attempt to re-invent the bicycle: https://github.com/PHPMailer/PHPMailer Why not to include this module in the TB?
dynambee Posted November 20, 2017 Posted November 20, 2017 @daokakao said in How to get copy sent to me of all customer order-related emails?: Taking in account all said above, it seems like an attempt to re-invent the bicycle: https://github.com/PHPMailer/PHPMailer Why not to include this module in the TB? 30bz includes Swift Mailer. I don't see any advantage to changing from Swift Mailer to PHPMailer, at least not for the issue currently at hand.
DaoKakao Posted November 20, 2017 Posted November 20, 2017 @dynambee said in How to get copy sent to me of all customer order-related emails?: I don’t see any advantage to changing from Swift Mailer to PHPMailer, at least not for the issue currently at hand Quote from phpmailer: Send emails with multiple To, CC, BCC and Reply-to addresses
dynambee Posted November 20, 2017 Posted November 20, 2017 Of course Swift Mailer supports those features. That isn't the problem here. The problem being discussed here was finding a way to have 30bz tell Swift Mailer to send those BCC messages. (Or alternatively to edit Swift Mailer itself to have it auto-send those BCC messages.) I have figured out and shared two different ways to make those BCC happen, one by editing the Mail.php file and one with a Mail.php override.
alwayspaws Posted November 20, 2017 Author Posted November 20, 2017 @dynambee I will try your solutions very soon. Thank you for them. From a merchant’s viewpoint, I wish that it was easier to do this and possibly keep it from being overwritten in the future.
alwayspaws Posted November 20, 2017 Author Posted November 20, 2017 @wakabayashi said in How to get copy sent to me of all customer order-related emails?: We use sendgrid for that purpose. It's free for us. I think it's a very good solution if your store is small. I took a quick look at it and I suppose it’s like other software. You use the trial and then you downgrade to free if you’re eligible, which I definitely am! Thank you.
dynambee Posted November 20, 2017 Posted November 20, 2017 @alwayspaws said in How to get copy sent to me of all customer order-related emails?: @dynambee I will try your solutions very soon. Thank you for them. From a merchant’s viewpoint, I wish that it was easier to do this and possibly keep it from being overwritten in the future. If you do the override it should be easy to make sure it doesn't get overwritten, or just keep a copy of the override file to put back after an update. Easier than having to edit files, too.
alwayspaws Posted November 20, 2017 Author Posted November 20, 2017 @dynambee i’ll definitely do that. I have a habit of emailing code to myself in case I need it in the future.
alwayspaws Posted November 20, 2017 Author Posted November 20, 2017 @mdekker said in How to get copy sent to me of all customer order-related emails?: Doesn't your outbound mail get collected by your provider? Do you mean our host if you’re on shared hosting?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now