Aria2: Automatic Email Notification on Download Completion
Preface
Since I have no coding background and have never learned anything about coding, my descriptions may not be very accurate. This script came to me when I was downloading movies. In today's society, everything is becoming intelligent, so I wanted to tinker and create an email download notification.
Screenshot

Building an Email System
I encountered quite a few problems during installation and debugging, but I searched around. Following this blogger's operation record, and with the help of Baota, you can usually configure it successfully. Just test it a few more times.
Finding and Modifying the Script
I first found a script modified by a user on the Enshan Wireless Forum for notification purposes.
In the script provided by the author, you just need to fill in the email information, but I had some problems with the sendmail command at the time, and then I followed the records in the first part. I've already written some of the script stuff to the server, so I changed a lot of the original script.
When I was debugging with the author's script, aria2.log kept showing the no such file or directory error, but I couldn't find the reason. Then I thought of writing all the scripts using pipes... It seems a bit stupid... but I don't know any other methods.
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 I actually worked on it for a long time to get a working one. Aria2通知 is the title of the email. The specific meaning of the parameters should be found in the article link 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 theabsolute addressof the script after=
In order to simultaneously achieve:
- Email notification
- Automatic upload
I call email.sh in the autoupload.sh script.
Specific writing method:
. /root/.aria2/email.sh
My Aria2 is using Aria2 一键安装管理脚本
Ending
I'm not very satisfied with this script myself. Although it can achieve basic functions, there are these problems:
- Two emails are sent for each download, one when the torrent download is complete and one when the file download is complete.
- I don't understand the syntax, I've tried
basename,##/and stuff like that, but I've tried for a long time and haven't been able to get the filename.
This is my first time writing an article, I don't know anything about layout, and it's quite verbose. But it's fun.