[TriEmbed] Raspberry Pi and eMail

Alan Wiggs alanwiggs at gmail.com
Tue Nov 10 16:38:31 CST 2015


As a backbone for sending emails thru GMAIL I am using old school ".bat"
files and "mailsend.exe".

https://code.google.com/p/mailsend/wiki/mailsendFAQ

I see it can also be used in Linux...

My only experience is running it as ".bat" files on Server 2012 R2.

In the first batch file:
>>
email.bat yyyyy at gmail.com receiver at yyyy.com "-ssl" 465 "-auth"
smtp.gmail.com "files of the day in PDF" "gmail password" C:\location of
files
>>

The file that looks for PDF files and attaches them to the
receiver at yyyy.com email
above.
And sends me a report with time and date of the event.

second batch file: email.bat
>>
::@echo off
setlocal
:: defaults
set from=yyyyy at gmail.com
set to=aw at yyyy.com
set subj="File Attachment"
set serv=smtp.gmail.com
set auth=yyyyy at gmail.com
set pass=gmail password
set filepath=C:\location
set port=465
set ssl="-ssl"
set auth="-auth"
:: Arguments
if "%~8" NEQ "" (
set from=%1
set to=%2
set ssl="%~3"
set port=%4
set auth="%~5"
set serv=%6
set subj="%~7"
set pass="%~8"
set filepath=%~9
)

c:
cd C:\location of files

:: format ReportLog
echo. >> ReportLog.txt
echo %date% %time% Starting script NEPTJ >> ReportLog.txt

:: Get names of files in directory, save to FileNames.txt
dir /b /s *.pdf >> FileNames.txt
IF ERRORLEVEL 1 (echo %date% %time% problem with retrieving file names >>
ReportLog.txt)

:: Count how many files are in FileNames, put into %NUMFILES%
for /f "tokens=3" %%i in ('find /v /c "SomeStringNotToBeFound"
filenames.txt') do set NUMFILES=%%i

IF %NUMFILES% EQU 0 GOTO ZEROFILES

:: loop through FileNames and send
For /f "tokens=1-2* delims=" %%B IN (FileNames.txt) DO (
echo file to email is %%B >> ReportLog.txt
mailsend.exe -to %to% -from %from% %ssl% -port %port% -auth %auth% -smtp
%serv% -sub "%%B" -M "%%B attached at %date% %time%" -attach "%%B" -user
%from% -pass "%pass%"
)
goto WRITELOG

:ZEROFILES
echo %date% %time% problem with retrieving number of current files >>
ReportLog.txt
mailsend.exe -to aw at yyyy.com -from %from% %ssl% -port %port% -auth %auth%
-smtp %serv% -sub "Problem with mailing" -M "Problem populating list of
files to be sent" -user %from% -pass "%pass%"

:WRITELOG
:: format ReportLog.txt
echo %date% %time% Ending Script >> ReportLog.txt
mailsend.exe -to aw at yyyy.com -from %from% %ssl% -port %port% -auth %auth%
-smtp %serv% -sub "Download report" -M "download report" -attach
"ReportLog.txt" -user %from% -pass "%pass%"
>>

As with anything the "" are important.

I pasted this from working code, just removed a few bits.
yyyy.com is not my mail server.

Respectfully,
Alan Wiggs


On Tue, Nov 10, 2015 at 3:21 PM, Mauricio Tavares via TriEmbed <
triembed at triembed.org> wrote:

> On Tue, Nov 10, 2015 at 3:05 PM, Grawburg via TriEmbed
> <triembed at triembed.org> wrote:
> > There was an article in Nuts & Volts at least a year ago about
> connecting a temp sensor to a Pi and e-mailing the results.
> > Of course, I can't find my PDF download and only have part of the Python
> script.  I'm going to keep looking, however.
> > I used the code and it worked fine.
> >
> > Here's another link I had:
> > http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/
> >
>       I've never tried that with my Pi; closest I've done was have a
> arduino + temp probe hung off one of the USB ports in my vmhost and a
> vm client would probulate it to get the temperature in python. A bit
> more Rube Goldbergish compared to your design though.
>
> >
> > Brian Grawburg
> >
> >
> >
> >
> >
> > _______________________________________________
> > Triangle, NC Embedded Computing mailing list
> > TriEmbed at triembed.org
> > http://mail.triembed.org/mailman/listinfo/triembed_triembed.org
> > TriEmbed web site: http://TriEmbed.org
>
> _______________________________________________
> Triangle, NC Embedded Computing mailing list
> TriEmbed at triembed.org
> http://mail.triembed.org/mailman/listinfo/triembed_triembed.org
> TriEmbed web site: http://TriEmbed.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.triembed.org/pipermail/triembed_triembed.org/attachments/20151110/08cfc97b/attachment.htm>


More information about the TriEmbed mailing list