Saturday, April 23, 2022

Setting up ssmtp (using a Gmail account) on Ubuntu/Linux

Since I have 2-factor authentication turned on for Gmail in order to get my Gmail account set up in ssmtp I had to set up an App Password. Below is a link to Google on how to do that, but I also listed the steps out. You will need to securely save that App Password. I will use APP_PASSWORD as a placeholder in the code, you need to replace that with your actual App Password.

Also, email isn't required so you can skip this step if you aren't comfortable with an App Password.

Reference: https://support.google.com/mail/answer/185833

  1. Goto your Google Account: https://myaccount.google.com/.
  2. Select Security.
  3. Under "Signing in to Google," select App Passwords. You may need to sign in. If you don’t have this option, it might be because:
    • 2-Step Verification is not set up for your account.
    • 2-Step Verification is only set up for security keys.
    • Your account is through work, school, or other organization.
    • You turned on Advanced Protection.
  4. At the bottom, choose Select app and choose the app you are using and then Select device and choose the device you’re using and then Generate.
  5. Follow the instructions to enter the App Password. The App Password is the 16-character code in the yellow bar on your device.
  6. Tap Done.

Now let's edit the ssmtp configuration file and add your Gmail details:

sudo nano /etc/ssmtp/ssmtp.conf

Change the root to your email address, change the mailhub to Gmail, and change the hostname to your computer.

GNU nano 4.8
root=username@gmail.com
mailhub=smtp.gmail.com:465
hostname=mycomputer

Finally, at the bottom of the configuration file, add the following lines. Be sure to update the

AuthPass

with your App Password from Google.

GNU nano 4.8
AuthUser=username@gmail.com
AuthPass=APP_PASSWORD
UseTLS=YES

Let's send a test email and make sure it works. Replace username@gmail.com with your email address.

printf "Subject: Testing SMTP Email\n\nThis is a test email." | /usr/sbin/ssmtp username@gmail.com

You should have received an email in your Gmail inbox.


Monday, December 6, 2021

How to Make an Envelope Template in Google Docs

                

Disclaimer
: I followed the steps below and printed on a Brother HL-3140CW series color laser printer using the custom feed tray for the envelope. You may need to make adjustments for your printer. I found it best to just print on normal Letter size paper first while setting up and once it appeared to be correct then I used the custom paper feed for an envelope and printed.


CREATING TEMPLATE

Create a new Google Doc

Go to File - Page Setup

Set Orientation to Landscape

Leave Paper Size set to Letter (8.5" x 11")

Set Top Margin to 2.5

Set Bottom Margin to 0

Set Left Margin to 1.5

Set Right Margin to 0

Click Ok.

Add placeholders for both the Return Address and the Mailing Address.

Note: You probably want to indent the Return Address one tab so it doesn't print right on the edge of the envelope. 

Name your document.


USING TEMPLATE

Open your new document (envelope template).

Go to File - Make a Copy

Then name this new version for this specific envelope you want to print.

Make adjustments to the Return Address and Mailing Address as needed.

Then print and you're finished.

Monday, March 28, 2011

How to email from batch file using Gmail









I'm a big fan of Gmail and Google Apps. During my day job I've wanted the ability to send an email as part of a batch file. So I thought I'd document my steps, mostly for my future reference, but if it will help you also, then all the better. I suppose I should start by saying I'm running 64-bit Windows 7, so my steps will cater to that specific environment. Let's begin... 1. Download and install "Stunnel" from www.stunnel.org 2. Download "Blat" from www.blat.net. There isn't a regular install for this program. It can be run from from a command line. I'll describe both the "setup" and how to run it below. You will end up with a copy of the Blat.exe program in the same location as your batch file. 3. Configure Stunnel with these settings for Gmail (same for Google Apps):
client=yes

[imaps]
accept = 143
connect = imaps.gmail.com:993

[ssmtp]
accept = 25
connect = smtp.gmail.com:465
I have IMAP turned on for my Google Apps account. If you prefer to use POP3, I believe you will want to replace the "[imaps]" section with:
[pop3s]
accept  = 110
connect = pop.gmail.com:995
4. If you wish to run Stunnel as a service in windows, run the following command from the install folder for Stunnel:
stunnel -install
5. Create a "profile" for Blat by entering the following command:
blat -install localhost name@address.com@127.0.0.1:1109
Be sure you use your email address and tack on "@127.0.0.1:1109" on the end of it. 6. And now, the command to put into the batch file to send an email:
blat - -body “The test was completed successfully.” -to send_to_email -subject “Blat Test Successful” -server localhost -p smtp -u your_email_address -pw your_password
NOTE: your_email_address must be a valid Gmail or Google Apps email account.