Hi,
This is a bit of code I have put together for sending email status reports to any given address.
I thought I would post it so that others may use it or adapt as reqd.
Code:
require("socket\\smtp")
socket.smtp.SERVER = "smtp.your server.com";
email = {
SendEmailMsg = function (self, msgtext, msgsubject, msgtype)
local r, e
self.msg = {
headers = {
from = "Girder Status Reports",
to = "Tony Blair",
subject = msgsubject or "Vote for me!..."
},
body = msgtext or ""
}
self.from = "<girder@No10.com>"
if msgtext then self.msg.body = msgtext end;
self.msg.body = "Automatically Generated System Report\n\n"..self.msg.body.."\n\nReport Compiled & Sent on "..os.date()
r, e = socket.smtp.send{
from = self.from,
rcpt = self.to,
source = socket.smtp.message(email.msg)
}
if r == 1 then
gir.LogMessage ("Email Status","Status Msg sent successfully - "..(msgtype or ""))
else
gir.LogMessage ("Email Status","Status Msg failed, err: "..e)
end;
end;
}
email.to = {
"<Tony@No10.com>",
"<Fred@the canary.com>",
}
email:SendEmailMsg ("Girder is working!\n\nGirder Started", "Girder Started", "Status");
Basically you call it using the following.
Code:
email:SendEmailMsg ([Message Test], [Message Subject], [Message Type]);
Message Type is used for indication in the logger.
Edit all the address as suits you. also put in your server etc.