Aria2 Download Completion Automatic Email Notification
Foreword
Since I have no coding foundation and have never studied programming knowledge, the descriptions in various aspects may not be entirely accurate. I thought of this script while downloading a movie. Society is moving towards intelligence, so I wanted to tinker around and set up an email download notification.
Screenshot

Email System Setup
I encountered many issues during installation and debugging, but I searched for solutions. Following this blogger's operation record, usually, it can be configured successfully with the help of BT Panel (Baota). Just test it a few more times yourself.
Script Finding and Modification
I first found a modified notification script posted by a user on the Right.com Wireless Forum.
In the script provided by that author, you just needed to fill in the email details, but I had some issues with the sendmail command at the time. So, I followed the documentation from the first part. Since some script elements were already written to the server, I changed many things in the original script.
When debugging with the author's script, the aria2.log kept showing the no such file or directory error, but I couldn't figure out why. Then I decided to write the entire script using pipes... It seems a bit clumsy... but I didn't know any other way.
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 create something functional. Aria2通知 (Aria2 Notification) is the email subject. The specific meaning of the parameters should be found in the article link mentioned in the first part.
Final Debugging
Specific steps:
- Upload the
email.shscript to the server - Modify the
on-download-complete=parameter inaria2.conf. Fill in the script'sabsolute pathafter the=.
To achieve both:
- Email notification
- Automatic upload
I call email.sh inside the autoupload.sh script.
Specific syntax:
. /root/.aria2/email.sh
I use the Aria2 One-Click Installation and Management Script for my Aria2.
Conclusion
I'm not entirely satisfied with this script myself. Although it fulfills the basic function, these are the issues:
- One download sends two emails: one email when the torrent finishes downloading, and one when the file finishes downloading.
- I don't understand the syntax. I tried
basename,##/, and similar methods, but I spent a long time trying and failed to get the file name successfully.
This is the first time I've written an article. I don't know how to do formatting, and it's quite verbose. But it was fun.