Jump to content

Send e-mail when completed


Xion

Recommended Posts

Posted

Hi!

First of all, great program.

But, I would like to receive an e-mail when a torrent has finished downloading.

If this function is build, is it possible to let the settings page look like this:

---------------------------------------------------------------------------

Send e-mail when:

1. [_] a torrent is added

2. [_] a torrent has completed downloading

3. [_] a torrent has completed seeding

4. [_] a torrent can't start (eg tracker is down or athorization fails)

SMTP Server : [_________________] Port : [____]

Username : [_________________]

Password : [_________________]

---------------------------------------------------------------------------

Options 1 and 4 would be usefull when using a folder is being monitored. Especially when it's a shared folder for other network users.

Posted
...

3. [_] a torrent has completed seeding

...

How can you be sure of this? :? A torrent, technically speaking, never completes seeding. Ever. There's always someone out there who'll connect later on that day/week, so how do you tell µTorrent when to stop? One way would be through a certain ratio, in which case the minimum should be 1:1. But it's always good manners to give back more to the community than you asked... ;)

Overall I feel it's a good idea, and I can see how this could be of great benefit if you're the admin of a large corporation. :)

Posted

I'd also vote against it, especially since it needs at least a rudimentary implementation of a new protocol (smtp).

...

3. [_] a torrent has completed seeding

...

How can you be sure of this? :? A torrent, technically speaking, never completes seeding. Ever. [...]

You could just say "... a torrent is no longer prioritized (utilizing seeding priority settings)"

I can understand how one would like a notification system like this though. Maybe this approach is just too specialized with E-Mail. Executing a command line instead might work. I'm sure there is some kind of command line tool out there that can send an email with just a single line (or use a batch- or .vbs-file instead...). As long as one can give the torrentname and other stuff as variables. Example:

on torrent download complete execute this command:

"c:program filessomescript.vbs" "%torname" "%ratio"

where %torname gets replaced by the torrentname of the torrent that just completed and triggered the execution of the command, and %ratio by it's current ratio (of course there should be more variables like these).

maybe this is also just overkill or would be implemented for only a hand full of people to use it. I wouldn't need it either for example :D

bye

Creat

Posted

I personally would like that UT telefones to the next shop and buy me a beer when a new torrent is done. Just kidding, i have a tool for you though that can solve your problem: macroexpress at www.macros.com. Easy to make a makro that checks your done Dir and sends you email about its content. ;)

Posted

My reason for asking a mail function is because I use uTorrent on a server, not on my 'Work'station. With a mail function I won't have look every day/hour/minute if a torrent has finished.

About the 'finished seeding', I thought torrents could be set to seed for a period of time. My mistake.

@Creat: That would be an excelent solution. Executing a program or script with parameters like %torrent_name% and %torrent_status% should do the trick.

Never change a winning team, so if the function is not implemented, no problem. At least the problem / request has been discussed :)

  • 4 years later...
Posted

Xion,

I had the same problem, so I created a script that sends me an e-mail when the torrent is finished. Here is how to use it:

Set up uTorrent, so that it will copy the .torrent file to a certain folder when the download is complete. In the script, in the settings section, change the "pathToMonitor" variable to the path where the finished torrents are copied to.

The script will check the folder every x minutes for new files, if a new file is found an e-mail message is sent. You can also choose to delete the file after the mail was sent successfully. (By unsuccessful message sending the file is not deleted).

You only need to set the correct settings under the "Settings" section to configure the message and SMTP information. I commented everything, so it should be understandable. You can start the script using a batch file (cscript.exe "<full path to the script>"). Or you can use a scheduled task to start the script everytime the server starts using the same command as in the batch file.

I have not been able to test the windows authentication setting, since I have no such server, however, smtp authentication works.

Here is the script (seems big, but it isn't - about 6 Kb), you need to put this code in a file with a ".vbs" extension:

Option Explicit
Dim pathToMonitor, checkInterval, deleteTorrentFiles, emailSender, emailRecipient
Dim smtpServer, smtpPort, smtpUsesWindowsAuthentication, smtpUsername, smtpPassword
Dim smtpUsesSSL, mailSubject, mailBody, fs, fileList, file

'#### SETTINGS ####

'Enter the full path to the folder the finished torrents are copied to
pathToMonitor = "C:\"

'Check for finished torrents every x minutes
checkInterval = "5"

'Should the finished torrents be deleted after notification?
'(True = yes, False = no)
'File existing in the folder when the program starts will be ignored)
deleteTorrentFiles = True

'E-mail address of the user sending the message
'This can be any e-mail address if the smtp server allows it
emailSender = "sender@domain.com"

'E-mail address to send the message To
emailRecipient = "recipient@domain.com"

'The name or IP of the smtp server
smtpServer = "domain.com"

'Server port to connect to (Normally port 25)
smtpPort = 25

'Use windows authentication?
'(True = yes, False = no)
'When set to true, smtpUsername, smtpPassword And
'smtpUsesSSL does not need to be configured
smtpUsesWindowsAuthentication = False

'Username for smtp authentication
smtpUsername = "username"

'Password for smtp authentication
smtpPassword = "password"

'Use ssl connection to connect to the smtp server?
'(True = yes, False = no)
smtpUsesSSL = False

'IN THE THIS SECTION THE FOLLOWING
'VARIABLES CAN BE USED:
'
'-> %filename% = Name of the torrent file
'-> %time% = Date and time the torrent was detected

'Subject to use in the mail
mailSubject = "Torrent Download Finished"

'Body test of the e-mail message (Plain text)
'\n will be replaced with a new line
mailBody = "The following torrent completed downloading at %time%:\n%filename%"

'#### END OF SETTINGS ####

'Create the filesystem object to watch the folder
set fs = CreateObject("Scripting.FileSystemObject")

'Check if the path to monitor exists
If(fs.FolderExists(pathToMonitor) = False) Then

'Path is not available
WScript.Echo "The path to monitor is not valid"
WScript.Quit
End If

'Get a list of existing files
fileList = ""

WScript.Echo "Creating file list..."
For Each file In fs.GetFolder(pathToMonitor).Files

'Add the file to the list
fileList = fileList & file.name & "|"
Next
WScript.Echo fileList
'Start monitoring the folder
WScript.Echo "Starting monitor..."
Do While (True)

'Wait the specified time
WScript.Sleep 60000 * checkInterval

'Check for new files
For Each file In fs.GetFolder(pathToMonitor).Files

'Check if the file is already listed
If(InStr(fileList, file.name) <= 0) Then

'Try sending the message, when ok, delete it when needed, else retain it
if(sendNotification(file.name) = True) then

'Check if the file needs to be deleted
If(deleteTorrentFiles = True) Then

'Delete the file
fs.DeleteFile file, True
Else

'Add the file to the file list if it does not need to be deleted
fileList = fileList & file.name & "|"
End If
End If
End if
Next
Loop

'Function to send mail message
Function sendNotification(FileName)

'Create the variables
Dim newMailSubject, newMailBody, emailMessage

'On errors continue, to prevent the script from quitting
On Error Resume next

'Create the message component
Set emailMessage = CreateObject("CDO.Message")

'Replace the variables with values
newMailSubject = Replace(mailSubject, "%filename%", FileName)
newMailSubject = Replace(newMailSubject, "%time%", Now())

newMailBody = Replace(mailBody, "%filename%", FileName)
newMailBody = Replace(newMailBody, "%time%", Now())
newMailBody = Replace(newMailBody, "\n", Chr(10))

'Set up the message
emailMessage.Subject = newMailSubject
emailMessage.Sender = emailSender
emailMessage.To = emailRecipient
emailMessage.TextBody = newMailBody

'Check if windows authentication is used
If(smtpUsesWindowsAuthentication = True) then

'Use windows authentication
emailMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 2
Else
'Use basic authentication
emailMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1

'Set the username and password
emailMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = smtpUsername
emailMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = smtpPassword

'Set SSL when needed
emailMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = smtpUsesSSL
End If

'Set the stmp settings
emailMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtpServer
emailMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = smtpPort

'Set remaining settings
emailMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
emailMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

'Save the settings
emailMessage.Configuration.Fields.Update

'Send the message
emailMessage.Send

'Check if there were errors
If(Err.Number <> 0) Then

'Display the error message
WScript.Echo Err.Description

'Clear the error
Err.Clear

'Re-enable error checking
On Error GoTo 0

'An error occured return false
sendNotification = False
Else

'Re-enable error checking
On Error GoTo 0

'No errors, return true
sendNotification = True
End If
End function

If you have any problems with the script, let me know, and I will try to help. Hope this helps some other people as well.

Greets,

Stitch10925

  • 11 months later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...