Page 1 of 2
How to send an email from NAS?

Posted:
Mon Nov 04, 2013 10:20 pm
by mdi
Hi,
I was looking for a way to have Transmission sending an email when a download completes.
I've seen that a script can be run when this happens, and the name of the script should be written in the config file. Ok so far.
So I tried to see what support for sending emails is available in the fvdw firmware, but except trying mail and a couple of other unknown commands found by googling, I couldn't do.
Is there any way to send an email from a shell script, so that this is achievable?
Thanks a lot,
MDI
Re: How to send an email from NAS?

Posted:
Mon Nov 04, 2013 10:35 pm
by fvdw
the sendmail binaries and basic files are present in the firmware...but it not setup. You will need data form smtp server of your provider and more. I did it in the past but forgot the details
also phpmailer is included in the firmware, thats easier to set up
currently I have no time to look at this, sorry, maybe later
Re: How to send an email from NAS?

Posted:
Mon Nov 04, 2013 10:38 pm
by mdi
Thank you fvdw, I'll make some tests on my own as soon as I get some time too.
Thanks for your quick answer anyway!
Re: How to send an email from NAS?

Posted:
Mon Nov 04, 2013 10:50 pm
by fvdw
below an example with phpmailer
phphmailer is in /usr/htdocs.
if i remember well the script must run from a subfolder in /usr/htdocs/PHPMailer
(This because of the line require_once('../class.phpmailer.php'); in the script, otherwise it cannot find this basic script)
- Code: Select all
<html>
<head>
<title>PHPMailer - SMTP (dummy) advanced test</title>
</head>
<body>
<?php
require_once('../class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP(); // telling the class to use SMTP
try {
$mail->Host = "mail.example.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "mail.example.com"; // sets as the SMTP server
$mail->Port = 465; // set the SMTP port for the server
$mail->Username = "username"; // mail server username
$mail->Password = "password"; // password for account on smtp server
$mail->AddReplyTo('info@dummy.com', 'First Last');
$mail->AddAddress('user@dummy.com', 'dummy user');
$mail->SetFrom('user@dummy.com', 'First Last');
$mail->AddReplyTo('user@dummy.com', 'First Last');
$mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
$mail->MsgHTML(file_get_contents('contents.html'));
$mail->AddAttachment('images/phpmailer.gif'); // attachment
$mail->AddAttachment('images/phpmailer_mini.gif'); // attachment
$mail->Send();
echo "Message Sent OK</p>\n";
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
?>
</body>
</html>
Re: How to send an email from NAS?

Posted:
Mon Nov 04, 2013 11:38 pm
by fvdw
I also found some notes from the past making it possible to sent e-mails using openssl without any other need to set anything. Should run with the firmware as it is using openssl at the command line
I think I will have time to post that on wednesday
Re: How to send an email from NAS?

Posted:
Fri Dec 06, 2013 9:03 pm
by fvdw
Hi mdi
are you still interested in this feature. In the meantime we managed to sent a simple e-mail by using an smtp mail server of an isp provider. No need to use sendmail or php mailer, just command line script and openssl.
Re: How to send an email from NAS?

Posted:
Mon Dec 09, 2013 4:46 pm
by wrumph
I think this would be a great feature to have!
-Will
Re: How to send an email from NAS?

Posted:
Mon Jan 06, 2014 11:15 am
by mdi
Hi fvdw,
Sorry for my absence. Yes, i'm still interested in a simple solution, which involves the fewer possible software layers.
Thanks a lot!
Re: How to send an email from NAS?

Posted:
Tue Feb 04, 2014 7:38 pm
by favroom
I would like a simple script to send email through my ISP's smtp server...
Thanks in advance!
Re: How to send an email from NAS?

Posted:
Tue Feb 04, 2014 8:12 pm
by Jocko
Hi favroom,
This will be available in version 15.1 and if all is ok it will be released within two weeks.
maybe you can wait this time ?