# For those using Gmail as SMTP

**URL:** https://forum.mautic.org/t/for-those-using-gmail-as-smtp/30799
**Category:** General Discussion
**Tags:** development
**Created:** [February 6, 2024, 9:02am UTC](https://forum.mautic.org/t/for-those-using-gmail-as-smtp/30799 "2024-02-06T09:02:44Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mchojrin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mchojrin/32/10159_2.png) [@mchojrin](https://forum.mautic.org/u/mchojrin)
#### Post date: [February 6, 2024, 9:02am UTC](https://forum.mautic.org/t/for-those-using-gmail-as-smtp/30799/1 "2024-02-06T09:02:44Z")

</div>

My Mautic version is: 4.4.11  
My PHP version is: 7.4.33

Hey, for anyone using Gmail as their SMTP, here’s a nice trick I put together to have Mautic recognize the emails and process them:

1. Create a Label called “Mautic” in my Inbox
2. Put this little script in a [Gmail App Script](https://script.google.com/home):

```auto
function myFunction() {
  let threads = GmailApp.getInboxThreads();
  var label = GmailApp.getUserLabelByName("Mautic");
  
  threads.forEach(function(thread, index, threads) {
    let message = thread.getMessages()[0];
    let header = message.getHeader('List-Unsubscribe');

    if (header.includes("https://mautic.leewayweb.com/email/unsubscribe/")) {
      thread.addLabel(label);
      Logger.log("Thread from mautic: " + thread.getFirstMessageSubject());
    }
  });
}

```

1. Setup my Mautic to fetch emails from the Mautic folder in my inbox.

Now my Mautic is tracking bounces 😀

---

<div class="post-metadata">

### Author: ![allweather](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/allweather/32/11325_2.png) [@allweather](https://forum.mautic.org/u/allweather)
#### Post date: [April 24, 2024, 6:03pm UTC](https://forum.mautic.org/t/for-those-using-gmail-as-smtp/30799/3 "2024-04-24T18:03:08Z")

</div>

You are appreciated
