I have made a custom module that allows a user to upload a CSV and import it using a FeedMe feed. This all works fine, however I want to send an e-mail to the user when the import has completed.

I have this so far, but realised it doesn't work because the event doesn't have access to the user session:

Event::on(Process::class, Process::EVENT_AFTER_PROCESS_FEED, function(FeedProcessEvent $event) {                
    $email = Craft::$app->getUser()->getIdentity()->email;
    if ($event->feed->id === getenv('USER_FEED_ID')) {
        $message = new Message();
        $message->setSubject("Import complete");
        $message->setHtmlBody('Data has been imported successfully');

I've been scratching my furry head but can't think of a solution, is there any way to do this?

1 Answer 1


As long as you have control of the CSV on upload, you could change its name to [email protected] (or some other properly escaped filename with the current user's email address in it). Then get the filename from the feed (must be in there somewhere) and extract the email address.

Bit of a workaround, but if it works, it works.

  • This is very creative I like it! However there may be times that another user selects a pre-uploaded CSV from another user so I'm not sure this will work for me. I will sit on it a little bit, but if it turns out this is the only way (which it seems it may be) I will give you that green tick!
    – dmatthams
    Feb 20, 2020 at 10:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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