How-To Geek

How To Get Email Notifications Whenever Someone Logs Into Your Computer


Do you have a computer that you don’t want other people accessing – perhaps a server? You can have Windows email you whenever someone logs into your computer (assuming it’s connected to the Internet), giving you peace of mind.

We’ll be using the Windows Task Scheduler for this – it can send emails in response to a variety of events. The Task Scheduler’s built-in email feature isn’t as flexible as we’d like, so we’ll be using another tool.

SendEmail vs. Task Scheduler Email Feature

The Task Scheduler includes a “send an email” option. Unfortunately, this won’t work properly for most users – if you have an SMTP server that requires authentication, the authentication details will have to be the same as the Windows user account’s details. The built-in emailing feature may be useful for users with SMTP servers running on their local computers, but it won’t work properly if you use Gmail or another third-party email service.

Instead, download SendEmail, a free tool for sending emails from the command line. With SendEmail, we can write a single command that will send out an email. SendEmail supports authentication, so we can easily send email from Gmail’s SMTP server or any other server that requires authentication.

Creating a Task

First, launch the task scheduler by typing Task Scheduler into your Start menu and pressing Enter.


Click the Create Task link in the sidebar.


On the General pane, provide a name and description for the task. You should also select the Run whether user is logged on or not option.


On the Triggers tab, create a new trigger that begins the task at log on for any user.


On the Actions tab, create a new action that runs the sendemail.exe application. Add arguments like the following:

-f -t -u Someone Logged Into Your Computer -m Someone just logged into your computer! -s -xu -xp password -o tls=yes

The above arguments sends an email from to The email’s subject is “Someone Logged Into Your Computer” and its message body is “Someone just logged into your computer!”. The server information is with port 587 – if you’re using a different SMTP server provider, you’ll have to change this. You’ll also have to replace password with your own password.


(Note that you can also select the Send an email action here if you have access to an SMTP server that doesn’t require authentication, such as an email server running on your local computer.)

On the Conditions tab, uncheck Start the task only if the computer is on AC power option or you won’t get emails if your computer is a laptop and it’s unplugged.


Click the OK button and save your task. You should now receive email notifications whenever someone logs into your computer.


You can use similar sendemail.exe commands attached to other trigger events to send other types of automatic emails. For example, you could send an automatic email on a schedule or in response to a certain event code in your computer’s Windows event log.

Chris Hoffman is a technology writer and all-around computer geek. He's as at home using the Linux terminal as he is digging into the Windows registry. Connect with him on Google+.

  • Published 09/4/12

Comments (19)

  1. JohnM

    so… if somebody does log in and goes to the task scheduler, they can see your gmail credentials in plain text?

  2. Chemx21

    I do see a use for this tutorial but I have encountered 2 issues.

    1.) Your email password is plainly visible in the created task. You can work around this by creating an email account with the only purpose of sending a logged in message.

    2.) The task will run the black command window on a successful login. To a trained user it will look suspicious and he/she might be prompted to check Task Scheduler. SendEmail needs to support a /silent argument.

  3. phanmo

    Will this still work with two-step verification switched on in Gmail?

  4. Ronnie

    I take it that this will only work on Win 7 Up but not XP?

  5. Tim

    You can also use “Blat” as a command line tool.

  6. Dan

    I’m curious if anyone knows a way to pass the logon user name as an argument to the email script to provide better detail.

  7. Kodess

    For the people scared of their password in plain sight:

    Use 2 step verification, and generate an app password.
    If someone really logged in and your scared he/she saw your password, just revoke access.

  8. Chris

    I can’t seem to overcome an error regarding TLS. Am I the only one with this error?

  9. Ragnarok

    I get a task scheduler error stating: “An error has occurred for task Email on Login. Error message: User account restriction error. The possible reasons are that blank passwords not allowed, or that a policy restriction has been enforced.”

    I did everything right, the passwords not blank and I don’t know about policy restrictions…Any ideas for solutions?

    thanks :D

  10. JonC

    @Ragnarok: just check the option “Do not store password….” on the General tab. It will work this way too.

  11. Nathan

    I would think that this could also work as a text message since a text message is essentially an e-mail. The only problem that you would probably run into is figuring out the password that was assigned by the service provider.

  12. Wendy

    I get an error of “failed: IO::Socket::INET: Connect: Unknown Error. Any ideas?

  13. Steve C

    I have an add-on idea for this. Here are the steps:

    1. Create a Gmail account to use for sending the email (don’t give out your real email passwords)

    2. When the user logs on, the computer’s web camera (either built-in or added on) snaps a photo

    3. The log-on message and photo are emailed to you

    The reason for the photo is in case your computer is stolen (would work better with a laptop).

    It’s Too bad laptops don’t have a GPS unit. Then, you could also send the computer’s location. It’s also too bad that you can’t get task scheduling ability on your smart phone and tablet. Otherwise, you could use the scheduler to send the same kind of emails.

  14. Stoffel

    I like the idea. But putting the gmail password in clear text is a no-no.

    Putting in more details would help as well : who logged in, current IP address, and so on :-)

  15. Bukk

    need better instructions for argument.

    -f -t -u Someone Logged Into Your Computer -m Someone just logged into your computer! -s -xu -xp password -o tls=yes

    I have a hotmail/live account.

    How do I input info into here???

  16. steven

    If you have your screensaver set to prompt for password, you won’t get an email from this task. This task only works for bootup and logoff/switch user.

    To also get emailed when unlocking from screensaver or sleep, add an identical task, but with trigger “On workstation unlock” instead of “At log on.”

  17. Skeeter

    If you have 2-step authentication set up in your Google account, just set up an application password for sendMail.

    If you want to have the command run silently so that the command prompt window doesn’t open, use the -q tag.

  18. MIIB1

    it work with me fine and send email when someone logo in but i don’t know how can i make it to send the user who log in How can make it send the name of the user (username).

  19. Rich

    Can’t get this to work…received a zero bye response back from server…tried all possible combinations; from what i’ve researched…i need some type of perl libraries installed for this to work and i have no idea how to compile all of that stuff…

More Articles You Might Like

Enter Your Email Here to Get Access for Free:

Go check your email!