13

Is there a way to have a copy of any message sent from a Gmail account sent to another address?

I've got any messages coming to my address copied to another (see this question for one solution, setting up filters is another), but I haven't yet found a way to have outbound messages automatically copied.

Is there a way?

6
  • You can try setting the forwarding rule for the condition from:me but I've never tried it before.
    – dnbrv
    Commented Mar 12, 2012 at 0:31
  • A from:me filter doesn't work (just tried it), probably because the filters are triggered on inbound messages.
    – ale
    Commented Mar 12, 2012 at 13:17
  • 1
    Agreed, it doesn't work. Commented Mar 12, 2012 at 14:19
  • Would be nice to be save/send a copy via the gmail interface. The easiest way might be to use the bcc field. It'd be a pain to type in a new address all the time, but that method would work.
    – JW8
    Commented Mar 12, 2012 at 16:56
  • Take a look at Collaborative inbox, a feature of Google Groups. Instead of email from the website going to a single person, have it delivered to a group instead. The collaborative inbox features makes it easy to see which requests has been handled. See support.google.com/a/bin/answer.py?hl=en&answer=167430 Commented Oct 30, 2012 at 10:06

7 Answers 7

5

You can certainly do this with https://script.google.com.

The limitation would probably be that the copy wouldn't occur instantly, but on a time-based trigger. Depending on what kind of account you have, and the volume of outgoing email, there might be a 5 minute or greater delay.

I don't know of a pre-made script that can do this, but you can adapt the one in the accepted answer here: How can I automatically forward Gmail emails when a label is applied?

In particular, you can search for label:sent emails from the last hour without a user label already_forwarded or something you create, then forward those messages with the script. Then, add the already_sent label so they don't get re-forwarded. Then, trigger the code to run every minute, 5 minutes, 10 minutes, or whatever your user account can bear.

The author of this script claims it can do what you want as well, though I haven't tried it: https://www.labnol.org/internet/auto-forward-gmail-messages/20665/

3

Set up a filter to apply a label to all your outgoing mail (From: [email protected] gets the label "outgoing") NOT under filters, but under forwarding, enable the forwarding of all mail to the single targeted address.

Restrictions:

If you try to do this solely using filters, the forwarding will not happen. You must enable forwarding of all mail to the intended recipient (the "manager") from the forwarding tab. You can't forward to multiple addresses this way unless you use the primary recipient address to then split the mail into many destinations. All mail both incoming and outgoing will be forwarded.

5
  • 4
    I'm trying to follow these instructions but I'm not quite clear about what I should do. So I create the outgoing filter, then go to Settings » Forwarding and tell Gmail to forward all mail to my target, and then what? Commented Oct 21, 2013 at 22:07
  • Yes, please would you explain your instruction steps in more detail
    – Richard
    Commented Mar 19, 2016 at 8:52
  • 2
    this does not work, please don't waste your time. Filters do not work on outgoing messages Commented Mar 22, 2017 at 14:23
  • 1
    @RobertSinclair , actually they do work, but not for all actions. Eg. labeling outgoing messages will work, but forwarding won't. And I'm of course totally agree with the your first statement about not wasting time, this answer is misleading and should be downvoted.
    – dess
    Commented Nov 13, 2019 at 23:23
  • I figured out a way that works using this answer! Create a filter (yes, a regular filter, using the filter tab in Settings), make the search condition "from:[email protected]", then give the filter TWO actions: apply a label of your choice AND forward. The labeling causes your sent message to go to your inbox, which I guess makes the forward action kick in. Minor annoyance: having to archive your sent message to remove it from the inbox. This answer helped, but is VERY confusing. The "NOT under filters" part is just wrong. Commented Mar 4, 2022 at 2:34
2

There is no way in Gmail to auto-forward sent emails to another account.

An option might be to use a mail client to drag and drop your sent mail from one account to another (or to batch forward). I'm sure with the right plugin for Thunderbird you could auto forward particular folders

2

Use Gmail Auto BCC for Greasemonkey.

/* This greasemonkey script automatically BCCs (or CCs) outgoing email from 
 * a gmail address to a specified email address
 *
 * Author: Jaidev K Sridhar mail<AT>jaidev<DOT>info
 * Version: v20130510-1
 * 
 * Copyright (c) 2005-2011, Jaidev K Sridhar
 * Released under the GPL license version 2.
 * http://www.gnu.org/licenses/gpl-2.0.html
 */

// ==UserScript==
// @name        Gmail Auto BCC
// @namespace   http://jaidev.info/home/projects/gmailAutoBcc
// @description This greasemonkey script automatically BCCs (or CCs) outgoing email from a gmail address to a specified email address. This version is for the "new" version of gmail (Nov 2007).
// @include     http*://mail.google.com/mail/*
// @include     http*://mail.google.com/a/*
// @version     v20130510-1
// ==/UserScript==

// Control parameters -- tweak in about:config
// gBccMail = email Address : Email address to BCC to
// gBccEnabled = true / false
// gBccPopup = true / false : Pops up a confirmation prompt before adding BCC
// gBccHeader = "bcc" : Header to add. By default BCC. Can be set to "cc".
// gBccMapFromAddress = true / false : Use different addresses for different
//                                     identities or different gmail accounts
// gBccLogging = 0-3 : Set log level (0-Disable, 1-Errors, 2-Warnings, 3-Verbose)
//

var redo_copy = 0;
var force_popup = false;        /* For non-firefox users */
var gmail = null;
var logging = 0;
var L_ERR = 1;
var L_WAR = 2;
var L_VER = 3;
var ga_retries = 0;
var TOCLS = "dK nr";
var TOLISTCLS = "am";
var REBTN1 = "T-I J-J5-Ji T-I-Js-IF aaq T-I-ax7 L3";
var REBTN2 = "mG";
//var FWBTN2 = "XymfBd mD";
var RABTN = "b7 J-M";
var SENDTOOLTIP = "Send";

function gBccLog (level, logmsg) {
    if (logging == 0) {
    logging = GM_getValue ('gBccLogging');
    if (logging == undefined) {
        logging = 1;
        GM_setValue ('gBccLogging', logging);
    }
    }
    if (logging >= level) {
    var d = new Date();
    GM_log ("<" + level + ">[" + d.toLocaleTimeString() + "] " + logmsg);
    }
}

function addBcc (tgt, oD) {
    var enabled = GM_getValue('gBccEnabled');
    if (enabled == false) {
    gBccLog (L_VER, "Script disabled");
    return;
    }
    else if (enabled != true) {
    /* We're probably running for the first time */
    GM_setValue('gBccEnabled', true);
    GM_setValue('gBccPopup', false); // FALSE by default
    GM_setValue('gBccMapFromAddress', true); // TRUE by default 
    GM_setValue ('gBccLogging', 1);
    enabled = true;
    }
    var form;
    var forms = oD.getElementsByTagName ('form');
    for (var i = 0; i < forms.length; i++) {
    if (forms[i].elements.namedItem ('bcc')) {
        form = forms[i];
        break;
    }
    }
    //if (tgt.form) {
    //  form = tgt.form;
    //}
    //else {
    //  if (tgt.getAttribute ('class') == REBTN) {
    //    form = tgt.parentNode.parentNode.nextSibling.firstChild.firstChild.firstChild.nextSibling.lastChild.firstChild.lastChild.firstChild.firstChild.firstChild.nextSibling.firstChild;
    //  }
    //  else if (tgt.getAttribute ('class') == RABTN) {
    //    form = tgt.parentNode.parentNode.nextSibling.firstChild.firstChild.lastChild.lastChild.firstChild.lastChild.firstChild.firstChild.firstChild.nextSibling.firstChild;
    //  }
    //}
    if (!form) {
    gBccLog (L_ERR, "No form");
    return;
    }
    var header = GM_getValue ('gBccHeader');
    if (!header || !(header == "cc" || header == "bcc")) {
    header = "bcc";
    GM_setValue ('gBccHeader', "bcc");
    }
    gBccLog (L_VER, "Header = " + header);
    var dst_field;
    if (header == "cc")
    dst_field = form.elements.namedItem('cc');
    else 
    dst_field = form.elements.namedItem('bcc');
    if (!dst_field) {
    gBccLog (L_ERR, "No dst");
    return;
    }
    var gStatus = dst_field.getAttribute ('gid');
    dst_field.setAttribute ('gid', "gBccDone");
    /* Get the address to cc/bcc to */
    var mapFrom = GM_getValue ('gBccMapFromAddress');
    var remove = false;
    if (form.elements.namedItem ('from')) {
    var from = form.elements.namedItem('from').value;
    }
    else {
    from = GM_getValue ('gBccCU');
    }
    if (mapFrom == true && from) {
    gBccLog (L_VER, "Mapping identities");
    var email = GM_getValue ('gBccMail_' + from);
    if (gStatus == "gBccDone" && redo_copy == 0) {
        if (tgt.nodeName == 'SELECT') {
        var lue = GM_getValue ('gBccLU');
        if (lue == null) {
            remove = false;
        }
        else if (lue == email) {
            gBccLog (L_VER, "Already copied");
            return;
        }
        var lu = new RegExp (lue + "(, )?");
        remove = true;
        }
        else {
        return;
        }
    }
    if (email == "disabled") {
        gBccLog (L_VER, "Disabled for sender " + from);
        if (remove == false)
        return;
        email = "";
    }
    if (!email) {
        email = prompt("gmailAutoBcc: Where do you want to bcc/cc your outgoing gmail sent from identity: " + from + "?\n\n Leave blank to disable gmailAutoBcc for this identity.");
        if (email == false) {
        GM_setValue ('gBccMail_' + from, "disabled");
        gBccLog (L_VER, "Disabling for sender " + from);
        if (remove == false)
            return;
        email = "";
        }
        else {
        GM_setValue ('gBccMail_' + from, email);
        gBccLog (L_VER, "Enabling for sender " + from + "; Copying " + email);
        }
    }
    }
    else {
    gBccLog (L_VER, "Not mapping");
    if (gStatus == "gBccDone" && redo_copy == 0) {
        /* Don't insert again! */
        gBccLog (L_VER, "Already copied");
        return;
    }
    var email = GM_getValue('gBccMail');
    if (!email) {
        email = prompt("gmailAutoBcc: Where do you want to bcc/cc all your outgoing gmail?");
        if (email == null || email == "" ) 
        return;
        GM_setValue('gBccMail', email);
        gBccLog (L_VER, "Enabling default, copying " + email);
    }
    if (mapFrom != false) 
        GM_setValue('gBccMapFromAddress', true); // TRUE by default
    }
    /* Should we confirm? */
    redo_copy = 0;
    var popup = GM_getValue ('gBccPopup');
    if ((popup == true || force_popup == true) && email != "" ) {
    if (confirm("Do you want to add BCC to " + email + "?") == false) {
        gBccLog (L_VER, "Not copying");
        return;
    }
    }
    else if (popup != false) {
    GM_setValue ('gBccPopup', false); // FALSE by default
    }
    if (dst_field.value) {
    if (remove) {
        var bcc_str = dst_field.value;
        if (bcc_str.match (lu)) {
        /* Remove old email */
        var new_bcc_str = bcc_str.replace (lu, "");
        var end = new RegExp ("(, )?$");
        dst_field.value = new_bcc_str.replace (end, "");
        gBccLog (L_VER, "Replaced " + lue + " with " + email);
        }
    }
    }
    if (email == "")
    return;
    if (dst_field.value) {
    dst_field.value = dst_field.value+", " +email;
    }
    else {
    dst_field.value = email;
    }
    gBccLog (L_VER, "Copied " + email);
    /* Don't repeat */
    GM_setValue ('gBccLU', email);
}

function gBccInit () 
{
    try {
    if (typeof (GM_getValue) != 'function')  {
            GM_log ("gmailAutoBcc: Greasemonkey function not available. If on Google Chrome or Chromium, re-install the script through TamperScript.");
    }
    var root = document;
    if (unsafeWindow.GLOBALS) {
            GM_setValue ('gBccCU', unsafeWindow.GLOBALS[10]);
    }
    root.addEventListener ("blur", function(event) {
        if (typeof (event.target.getAttribute) == 'function') {
        var tg_cl = event.target.getAttribute ("class");
        if (!tg_cl) return;
        if (tg_cl.match (TOCLS)) {
            gBccLog (L_VER, "Trigger = field");
            window.setTimeout (addBcc, 500, event.target, event.target.ownerDocument);
        }
        else if (tg_cl.match (REBTN1) || 
             tg_cl.match (RABTN)) {
            gBccLog (L_VER, "Trigger = timeout");
            window.setTimeout (addBcc, 500, event.target, event.target.ownerDocument);
        }
        else {
            //gBccLog (L_VER, "blur: " + tg_cl);
            return;
        }
        }
    }, true);
    root.addEventListener ("change", function (event) {
        if (event.target.getAttribute ('name') == 'from') {
        gBccLog (L_VER, "Trigger = sender change");
        addBcc (event.target, event.target.ownerDocument);
        }
        else if (event.target.getAttribute ('name') == 'to') {
        gBccLog (L_VER, "Trigger = to");
        window.setTimeout (addBcc, 500, event.target, event.target.ownerDocument);
        }
    }, true);
    root.addEventListener ("click", function (event) {
        if (typeof (event.target.getAttribute) == 'function') {
        var tg_cl = event.target.getAttribute ("class");
        if (tg_cl && tg_cl.match (REBTN2))
        {
            gBccLog (L_VER, "CLICK: " + tg_cl);
            redo_copy = 1;
            window.setTimeout (addBcc, 500, event.target, event.target.ownerDocument);
        }
        else {
            //gBccLog (L_VER, "CLICK: " + tg_cl);
        }
        var tip = event.target.getAttribute("data-tooltip");
        if (tip && tip.match (SENDTOOLTIP)) {
            addBcc(event.target, event.target.ownerDocument);
        }
        }
    }, true);

    gBccLog (L_VER, "Initialized Script");
    }
    catch (ex) {
    GM_log ("gmailAutoBcc: Exception '"+ ex.message);
    if (ga_retries < 3) {
        ga_retries ++;
        window.setTimeout (gBccInit, 250);
    }
    }
} /* gBccInit */

window.setTimeout (gBccInit, 750);
0
1

As far as I know, there are two ways you can do it. One of which is creating a distribution list and add all of the emails to it and she'll have to do a reply all or you can install this Greasemonkey script, that will do kind of what you want.

1

I made a PHP library to just do that: fog

You just have to copy the files on a web server, customize the use.php file and call your page from cron or from a webcron like MyWebCron.

Folder name part from $hostname variable has to be customized as well to match your inbox name.

4
  • Since my question was a few months before the other, I think the other would be the duplicate. But thanks for pointing me to the answer. Commented Oct 29, 2012 at 17:24
  • you are right, so I put the answer here
    – Ka.
    Commented Oct 30, 2012 at 22:03
  • ka, I am not very technical, how can I receive copies of sent mails automatically to another mail (assume both are gmail accounts) Thanks
    – user41586
    Commented Jun 7, 2013 at 6:15
  • @yousuf, I don't know any existing service that do that, but if you really need it, please, get in touch with me by mail ([email protected]), I'll send you a proposal. If you have a developer around you, he can use my code (and even improve it :)
    – Ka.
    Commented Jun 7, 2013 at 10:45
1

Yes, https://script.google.com/ seems to be the way to go, thanks @MZ_Guy. The following script worked for me, run by a Trigger every 5 minutes (via a stopwatch icon on the right currently).

I went with the approach of forwarding everything since the last invocation of the script, because labels are for the whole thread (at least in the API currently), and I wanted to be able to support individual messages in a thread over time. Also excluded drafts. My only other addition is to exclude messages explicitly sent to the address to which we're forwarding, because I need support for that too.

function forwardOutgoingMail() {
  var forwardingAddress = '[email protected]';
  var forwardingMinutes = 7; //remember to change if you change the trigger
  var myOwnAddress = '[email protected]';

  var timeFrom = Math.floor(new Date().valueOf()/1000) - 60 * forwardingMinutes;
  var threads = GmailApp.search('from:' + myOwnAddress + ' after:' + timeFrom + ' -to:'+forwardingAddress);

  for (var i = 0; i < threads.length; i++) {
    var messages = threads[i].getMessages();
    var forwarded_ids = new Set();
    for (var j = 0; j < messages.length; j++) {
      var message = messages[j];
      // console.log(message.getHeader("Message-ID")+ " " +message.getHeader("References"));
      // console.log(message.getRawContent());
      if (message.getFrom().toLowerCase().includes(myOwnAddress) && message.getTo().toLowerCase().includes(forwardingAddress)) {
        forwarded_ids.add(message.getHeader("References"));
      }
    }
    for (var j = 0; j < messages.length; j++) {
      var message = messages[j];
      if (!(message.getFrom().toLowerCase().includes(myOwnAddress) && message.getTo().toLowerCase().includes(forwardingAddress))
      && !message.isDraft()
      && !forwarded_ids.has(message.getHeader("Message-ID"))) {
        message.forward(forwardingAddress);
        // console.log(message.getRawContent());
      }
    }
  }
}

When you first set this up, be prepared to grant scary looking permissions to script.google.com as prompted.

(Regarding other possible approaches: I couldn't get gmail filters to forward outgoing messages, even if my filter also added a label, and no matter what i did in the Forwarding tab. Besides the goodness of using google's scripting site to script google's own gmail, I didn't go with greasemonkey because I wanted it to also work when I'm only using the phone app. The script above requires your address because "from:me" didn't work for me properly.)

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