-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMailAlert.m
54 lines (49 loc) · 1.64 KB
/
MailAlert.m
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 = '[email protected]';
case 'Paul'
address = '[email protected]';
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','[email protected]')
setpref('Internet','SMTP_Server','smtp.gmail.com')
setpref('Internet','SMTP_Username','[email protected]')
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