How to send an email from NAS?

How to send an email from NAS?

Postby mdi » Mon Nov 04, 2013 10:20 pm

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
mdi
Donator VIP
Donator VIP
 
Posts: 193
Joined: Tue Oct 11, 2011 1:20 pm

Re: How to send an email from NAS?

Postby fvdw » Mon Nov 04, 2013 10:35 pm

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
fvdw
Site Admin - expert
 
Posts: 13471
Joined: Tue Apr 12, 2011 2:30 pm
Location: Netherlands

Re: How to send an email from NAS?

Postby mdi » Mon Nov 04, 2013 10:38 pm

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!
mdi
Donator VIP
Donator VIP
 
Posts: 193
Joined: Tue Oct 11, 2011 1:20 pm

Re: How to send an email from NAS?

Postby fvdw » Mon Nov 04, 2013 10:50 pm

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>
You do not have the required permissions to view the files attached to this post.
fvdw
Site Admin - expert
 
Posts: 13471
Joined: Tue Apr 12, 2011 2:30 pm
Location: Netherlands

Re: How to send an email from NAS?

Postby fvdw » Mon Nov 04, 2013 11:38 pm

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
fvdw
Site Admin - expert
 
Posts: 13471
Joined: Tue Apr 12, 2011 2:30 pm
Location: Netherlands

Re: How to send an email from NAS?

Postby fvdw » Fri Dec 06, 2013 9:03 pm

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.
fvdw
Site Admin - expert
 
Posts: 13471
Joined: Tue Apr 12, 2011 2:30 pm
Location: Netherlands

Re: How to send an email from NAS?

Postby wrumph » Mon Dec 09, 2013 4:46 pm

I think this would be a great feature to have!

-Will
wrumph
Donator VIP
Donator VIP
 
Posts: 19
Joined: Sat Jan 26, 2013 11:55 pm

Re: How to send an email from NAS?

Postby mdi » Mon Jan 06, 2014 11:15 am

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!
mdi
Donator VIP
Donator VIP
 
Posts: 193
Joined: Tue Oct 11, 2011 1:20 pm

Re: How to send an email from NAS?

Postby favroom » Tue Feb 04, 2014 7:38 pm

I would like a simple script to send email through my ISP's smtp server...

Thanks in advance!
favroom
 
Posts: 71
Joined: Thu Dec 13, 2012 7:09 am
Location: Netherlands

Re: How to send an email from NAS?

Postby Jocko » Tue Feb 04, 2014 8:12 pm

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 ?
Jocko
Site Admin - expert
 
Posts: 11529
Joined: Tue Apr 12, 2011 4:48 pm
Location: Orleans, France

Next

Return to Lacie Network Space vs2 and max version

Who is online

Users browsing this forum: No registered users and 5 guests