---
title: "Incoming Mail Handler"
canonical: "https://support.appfire.com/space/PSJC/1166835713/Incoming%20Mail%20Handler"
format: markdown
---
> Macro (aura-html)



Incoming emails can be efficiently processed using SIL scripting, providing an unparalleled level of flexibility. Review the following video for an overview of this feature.

The sample script used in the video is listed below. For more details, please see the [configuration page](https://appfire.atlassian.net/wiki/spaces/PSJC/pages/994018140) that describes this feature.

```
IncomingEmail mail = getIncomingEmail();

string issueKey = mail.subject;
if(issueExists(issueKey)) {
    // add comment

    string commentText = mail.body;
    string userCommenting = getUserByEmail(mail.from).key;
    
    addComment(issueKey, userCommenting, commentText);
    attachAllFilesFromEmail(issueKey);
    
} else {
    // create issue
    
    string summary = mail.subject;
    string description = mail.body;
    
    string [] fields = {};
    fields += {"reporter", getUserByEmail(mail.from).key};
    
    createIssue("PROJECT NAME", "", "Task", summary , "Minor", description, {}, "", "", fields);
}
```