forked from torbenott/BpodFunctions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMailAlert.m
More file actions
54 lines (49 loc) · 1.64 KB
/
MailAlert.m
File metadata and controls
54 lines (49 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
function MailAlert(persons,subject,msg)
%persons is a cell array with string containing recipient names
if iscell(persons)
for i = 1:length(persons)
person=persons{i};
switch person
case 'Torben'
address = 'm6a1c5v4i4m5t5t0@kepecslab.slack.com';
case 'Paul'
address = 'n1g4g9a6v7u9s9s8@kepecslab.slack.com';
otherwise
fprintf('Add person to mail list on MailAlert.m\n');
return
end
SendMyMail(address,subject,msg);
end
end
end
% sends mail from Kepecslab's cshl gmail account
% 3 or 4 inputs: address,subject,message,cell with attachment paths
% (each as string)
function sent = SendMyMail(varargin)
sent = false;
setpref('Internet','E_mail','kepecslab.cshl@gmail.com')
setpref('Internet','SMTP_Server','smtp.gmail.com')
setpref('Internet','SMTP_Username','kepecslab.cshl@gmail.com')
setpref('Internet','SMTP_Password','D3cision')
props = java.lang.System.getProperties;
props.setProperty('mail.smtp.auth','true');
props.setProperty('mail.smtp.socketFactory.class', 'javax.net.ssl.SSLSocketFactory');
props.setProperty('mail.smtp.socketFactory.port','465');
if length(varargin)==3
try
sendmail(varargin{1},varargin{2},varargin{3})
sent=true;
catch
display('Error:SendMyMail:E-Mail could not be sent.')
end
elseif length(varargin)==4
try
sendmail(varargin{1},varargin{2},varargin{3},varargin{4})
sent=true;
catch
display('Error:SendMyMail:E-Mail could not be sent.')
end
else
display('Error:SendMyMail:Number of input arguments wrong.')
end
end