emails from command prompt.

Doug Stewart doug.dastew at gmail.com
Sun Jun 11 21:18:42 UTC 2017


On Sun, Jun 11, 2017 at 4:27 PM, Aruna Hewapathirane <
aruna.hewapathirane at gmail.com> wrote:

> > From: Doug Stewart <doug.dastew at gmail.com>
> > Date: Sun, Jun 11, 2017 at 3:29 PM
> > Subject: emails from command prompt.
> > To: ubuntu-ca- at lists.ubuntu.com
>
> > I would like to make a scrip, that will be a cron job, and will send an
> email to myself through gmail system.
> > I am looking at sendmail but don't understand how to configure it.
> > I normally use a browser to get and sent emails through gmail so I do
> not have any emal servers running on my comp.
> > any help would be appreciated.
>
> Hello Doug,
>
> The easiest way is to use Python. Put the below code in a file, say
> gmail.py then run.
>
> ------------------------------------------------------------
> -------------------------------------------------------------
> import smtplib
>
> server = smtplib.SMTP('smtp.gmail.com', 587)
> server.starttls()
> server.login("YOUR EMAIL ADDRESS", "YOUR PASSWORD")
>
> msg = "YOUR MESSAGE!"
> server.sendmail("YOUR EMAIL ADDRESS", "THE EMAIL ADDRESS TO SEND TO", msg)
> server.quit()
> ------------------------------------------------------------
> ----------------------------------------------------------------
>
> Substitute your actual email adress where is says "YOUR EMAIL ADDRESS"
> and your actual password in "YOUR PASSWORD" and the email address you
> want to send to in "THE EMAIL ADDRESS TO SEND TO"
>
> Tested and works on my system, and you can put that in a bash script and
> tell cron to run.
>
> Hope this helps - Aruna ( Configuring postfix and smtp can be a process
> that causes hair loss and baldness :)
>
>
> --


Thanks I have this working now!!!

One more question.
I want to send a small file. I will look, but if you know how then I am all
ears :-)


-- 
DAS[image: Certificate for 206392]

<https://linuxcounter.net/user/206392.html>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-ca/attachments/20170611/447b7a89/attachment.html>


More information about the ubuntu-ca mailing list