I have not tested the code below, but this is the most basic structure of what you are trying to do.
On Arduino, configure your code to output something on the serial line ("arduino_output") when you want to send an email. Then on the computer, wait for this event.
Linux is very simple because the serial port can be handled in the same way as reading a file.
use open ':std';
use MIME::Lite;
open FILE, "<", "/dev/usbTTY0" or die $!;
$msg = MIME::Lite->new(
From => '"FirstName LastName" <something@gmail.com>',
To => "somebody@hotmail.com",
Subject => "subject",
Type => "text/plain"
);
while (1){
while (<FILE>){
if ($_ == "arduino_output"){
MIME::Lite->send('smtp','mailrelay.corp.advancestores.com',Timeout=>60);
$msg->send();
}
}
}
Good luck with your project.
ZnArK source
share