How to send email without a 'Compose' prompt

This tutorial requires the following:

  • Android Scripting Environment to be installed.
  • The Python interpreter to be installed within ASE
  • A little text editing to make the script work with your email account

Get the script!

  1. First, you will need to download the following script:
  2. Copy the script into your ase/scripts/ directory on your device.

Edit the script!

  1. Open up ASE
  2. Long tap on and choose Edit
  3. Scroll down past the lengthy documentation comments to the following lines, and edit these to match your Gmail/Google Apps login details.
    • If you want to use another email provider, I have included some fallbacks to allow for other mail providers: Please read the documentation I've provided in the comments at the top of the script for details on editing the script to match your configuration.
    email_name = '' # Optional - A friendly name for the 'From' field
    email_user = '<gmail/google apps username>'
    email_pass = '<gmail/google apps password>'

Create the mail configuration file in Tasker

  1. Create a new Task.
  2. Click on the + button.
  3. Click on File, then Write File
  4. Enter the location as tmp/mailout.conf
  5. Enter the details for the email to send and make sure that Append is unticked before you click Done. Here's a template file to get you started! Please note that all prefixes (mailto etc.) are case sensitive!:
subject: This is the subject
This is the body of the message. Replace it with your own.
Note that the actual message begins AFTER the first line break after body:
Line breaks and spacing should be preserved by most mail clients.
Most clients will also handle text wrapping automatically.
This will be read all the way until the end of the file.
Remember that you can use %VARIABLES in any of these fields! :)

Run the script from within Tasker

  1. Click on the + button again.
  2. Choose Misc, then Run Script
  3. Long tap on the name, and choose
  4. Make sure that Terminal is unticked, and click Done.

Clean up your files

  1. Click on the + button again.
  2. Choose Tasker, then Wait
  3. Enter a wait period of 1 minute - The script needs time to connect to the server and send the email before you delete the conf file!
  4. Click Done
  5. Click on the + button again.
  6. Choose File, then Delete File
  7. Enter tmp/mailout.conf in the File field. Click Done.
  8. You're done!

Possible Issues

The script doesn't send email

Try running it with Terminal ticked and see what comes out; the script outputs details on errors if you mess things up, and there are a number of issues that might crop up, such as:

  1. Your username/password might not be correct.
  2. You've not specified a valid email address in your mailto: field
  3. You didn't enter the body text correctly: There needs to be a line break after 'body:' before your message!
  4. It can't find the mailout.conf file: This script was written for my HTC Desire - The directory Tasker writes in may not be the same on your phone as it is on mine (tmp/mailout.conf writes to /mnt/sdcard/tmp/mailout.conf for me) [For the Droid X, delete the "/mnt" part of this path] - As Tasker cannot currently specify arguments when running scripts, you will need to edit the default conf_file string to fix this. The script itself will happily accept a custom conf location if you specify it in the arguments, or accept the mailto, subject and body as a set of three arguments if you like, but Tasker doesn't allow this - I've at least prepared the script for when Tasker will let you do this, however :)
  5. You don't have a data connection, so you can't send an email! - This should pop up in the terminal as 'Name or service not known'

this is not working using Python3 APK R6 and SL4A Release 6

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License