5

How can I configure FogBugz to Bcc a set email address on every outgoing mail sent?

flag

3 Answers

5

Update: As of FogBugz 8, this might be possible by writing a plugin which would send an email to the BCC address. The original answer below is still the simplest solution we've found, though.


We find that the best way to approach adding this sort of functionality is actually to do it at the SMTP level. If you can configure your outbound mail server to add the BCC, that would prevent any changes to FogBugz from interfering.

For example, Postfix has the setting always_bcc

You can also achieve this functionality via your database. The following code (for MySQL) sets up an automatic BCC feature without changing the FogBugz source. This example is more sophisticated and only adds the Bcc to destination@example.com if the destination is something@example.com:

CREATE TRIGGER `FogBugz`.`add_bcc`
BEFORE INSERT ON `FogBugz`.`MailQueue`
 FOR EACH ROW BEGIN
  IF (NEW.sHeaders LIKE "%something@example.com%"
      AND NEW.sHeaders RLIKE 'Bcc:...$') THEN
    SET NEW.sHeaders = REPLACE(NEW.sHeaders, "X-Bcc: ", "X-Bcc:
destination@example.com");
  END IF;
END
link|flag
Is it possible to do either of these with an On Demand account? The messages are sent using the Fog Creek SMTP server, not mine, and I don't have direct access to the SQL database. – Michael Tsai Aug 31 2010 at 14:49
1

In case anyone else needs it, here is the solution I came up with for creating this trigger in TSQL. It adds the Bcc address to the X-Recipients field and adds a Bcc MIME header. Nothing in our mail queue had used X-Bcc and it seems to work fine without it.

CREATE TRIGGER tr_MailQueue_Bcc ON MailQueue
INSTEAD OF INSERT
AS

INSERT MailQueue (
dt, sHeaders,   sMessage,   cTries, nType,  ixOther)
SELECT
    GETDATE(),
    CAST(
    REPLACE(
        REPLACE(
            CAST(sHeaders AS NVARCHAR(max)),
            'X-Receiver: ',
            'X-Receiver: "user@host.com" <user@host.com>, '
        ),
'
Subject:',
'
Bcc: "user@host.com" <user@host.com>
Subject:'
    ) AS NTEXT),
    sMessage,
    cTries,
    nType,
    ixOther
FROM inserted
GO
link|flag
0

I have tried the above in SQL Server, however am having problems with the format of the header. If you do not manually BCC someone when sending the email, there is no X-Bcc tag to replace.

I have tested the BCC to determine the format of the header, and tried to add the X-Bcc directly before the MIME section, however it seems there is some formatting being lost as it then is interpreting the "MIME-Version: 1.0" string as part of the email address.

Has anyone written a solution for SQL Server?

link|flag
Not that we're aware of. You might try duplicating the row on insert, with a new To address. – FogBugz FAQ Jun 1 2010 at 14:35
I would need to replace the "X-Sender" as well as the "To" address, and there may be multiple of these, so the string parsing is getting a bit complex. Also it would be nice to see who the email was actually sent to. I was really looking for a "quick fix" for this since we haven't been able to get it to work via Exchange (for external emails). – Jenny Jun 2 2010 at 3:28
We don't support modifications to the source code, but we ship the full source of FogBugz in your-fogbugz-directory/src-Website. You can try modifying the SendMessage method in CMailQueue.was and rebuilding FogBugz: fogbugz.stackexchange.com/questions/1327/… – adambox Jun 2 2010 at 18:40

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.