Document information

Document ID: 5467
Subject: Send Uploaded Files Directly to Printer
Creation date: 7/29/21 4:17 PM
Last modified on: 7/30/21 8:58 AM


Send Uploaded Files Directly to Printer

Your office may have a printer that is designed to accept email attachments and print them out. You can use SynaMan to send uploaded files as attachments to that address automatically.

Windows Configuration

Setting up triggers on a Windows environment requires a few steps.

Step 1: Powershell

Step 1 is to create the powershell script that will actually send the email. Copy paste the contents below into a new script, such as “sendEmail.ps1”.

You will need to modify a few lines in the above code:

$outgoingUsername - This is the username to authenticate with your SMTP server
$outgoingPassword - This is the password for that username.
$outgoingServer - This is the smtp server address for your smtp server, such as smtp.google.com
$outgoingPortSMTP - This is the port number the SMTP server is listening on.
$outgoingToAddressList - This is the recipient email address of the printer.
$messageSubject - subject of the email.
$messageBody - body of the email.

You will notice that there is also this line:

$outgoingAttachmentURLList = @( $args[0] )

This means that any file path that we pass into this command will be added as an attachment.

Step 2: Batch File

We now need to create a batch file that will run the powershell script we just created as well as give it the path for the file that was just uploaded.

Open notepad and paste the following content into the file:

Powershell.exe -executionpolicy remotesigned -File C:\pathToPowershellScript\sendEmail.ps1 %1

Modify the path to be the full path to the powershell script you created earlier.

Save the file as “sendEmail.bat”

Linux Configuration

For Linux machines, we can use the s-nail package since it let’s us specify external SMTP servers.

First, install s-nail:

$ sudo apt-get install s-nail

Next, we need to create a script that SynaMan will call in it’s trigger.

Let’s call this sendMail.sh, here are it’s contents:

$ echo "Message Body" | s-nail -v \
> -r "recipient@example.com" \
> -s "Subject" \
> -attach=$1
> -S smtp="mail.server.com:587" \
> -S smtp-use-starttls \
> -S smtp-auth=login \
> -S smtp-auth-user="sender@example.com" \
> -S smtp-auth-password="Password" \
> -S ssl-verify=ignore \
> recipient@yourcompany.com

Next, you need to modify the above code with your SMTP settings, including the body, recipient, and subject.

You’ll notice in the above code body there is a “$1” next to the attachment field. This is a command line argument that we will pass from SynaMan to the script. The remaining fields should be static, as the same user will be sending to the same recipient in all cases.

Configure SynaMan

Once you've setup the appropriate scripts, the next step is to configure the trigger in SynaMan.

  • In SynaMan’s admin console click on CONFIGURATION and then TRIGGERS in the top right.
  • Click on ADD NEW TRIGGER.

  • The following parameters must be specified:

  • Friendly Name: A name to distinguish this trigger from other triggers, such as “Send Email on Upload”
  • Executable Path: The full path to the batch file or Linux script you just created such as C:\Documents\sendEmail.bat or /opt/sendMail.sh.
  • Parameters: You will want to enter “$FILE_NAME”
  • Event Type: select Upload.
  • Click Save Trigger.

Now, any time anyone uploads a file, SynaMan will call the batch file that will call the powershell script or the linux script and email your printer’s email address a copy of the file as an attachment.





Add a comment to this document

Do you have a helpful tip related to this document that you'd like to share with other users?

Important: This area is reserved for useful tips. Therefore, do not post any questions here. Instead, use our public forums to post questions.

Navigation

Social Media

Powered by 10MinutesWeb.com