• Home
  • Blog
  • Stack

© 2026 YIKZERO

Sending Email Notifications When Aria2 Downloads Complete

Develop· February 9, 2020
This article was translated from Chinese with GPT-5.5. If there are any discrepancies, please refer to the original Chinese version.

Preface

Since I don’t really have any coding background and have never studied anything related to code, some of my descriptions may not be very accurate. I thought of this script while downloading movies. Nowadays, everything in society is becoming intelligent, so I also wanted to tinker around and make an email download notification.

Screenshot

Email Screenshot
Email Screenshot

Setting Up the Email System

I ran into quite a few problems during installation and debugging, but after searching around and following this blogger’s operation record, together with Baota, it can generally be configured successfully. Just test it a few more times yourself.

Finding and Modifying the Script

I first found a notification script modified by the original poster on the Enshan Wireless Forum.

In the script provided by that author, things like the email address just need to be filled in. However, at the time, I had some issues with the sendmail command, so I followed the records in the first section. Some of the script-related things had already been written into my server, so I changed a lot of the original script.

When I was debugging with the author’s script, the aria2.log kept showing the problem no such file or directory, but I couldn’t find the cause. Then I thought I would write the entire script using pipes... It seems a bit clumsy... but I didn’t know any other method.

echo "

文件路径:$3

完成时间 `date +%Y/%m/%d`  `date +%T`

负载 "`uptime`"

版本 "`uname -a`"

From Zero.

Have a nice day." | mail -s 'Aria2通知' example@qq.com

This is the content of my script. It’s very simple, right... But it actually took me a long time to make something usable. Aria2通知 is the email subject. The specific meanings of the parameters should all be found in the article link in the first section.

Final Debugging

Specific steps:

  1. Upload the email.sh script to the server
  2. Modify the on-download-complete= parameter in aria2.conf; after =, fill in the script’s absolute path

In order to achieve both:

  • Email notification
  • Automatic upload

I call email.sh from the autoupload.sh script

Specific writing:

. /root/.aria2/email.sh

My Aria2 uses the Aria2 One-Click Installation Management Script

Conclusion

I’m not very satisfied with this script myself. Although it can implement the basic functions, it has the following problems

  1. One download will send two emails: one email when the torrent download completes, and one email when the file download completes.
  2. I don’t understand the syntax. I tried things like basename and ##/, but after trying for quite a while, I still couldn’t successfully get the filename.

This is my first time writing an article. I don’t know anything about formatting, and it’s also quite wordy. But it was pretty fun.

Sharing Dorm WiFi: Bypassing Campus Network Restrictions