Matlab 程序结束后发送短信或者邮件

您所在的位置:网站首页 matlab发送邮件 Matlab 程序结束后发送短信或者邮件

Matlab 程序结束后发送短信或者邮件

2024-07-13 21:15| 来源: 网络整理| 查看: 265

然后,在matlab命令窗口(command window),输入: doc sendmail,函数介绍如下:

复制代码 1 2 3 4 5 6 7 8 9 10 MailAddress =  '[email protected]' ;% 发送地址 password =  'XXXX' ;  %密码 setpref( 'Internet' , 'E_mail' ,MailAddress); setpref( 'Internet' , 'SMTP_Server' , 'smtp.126.com' );%SMTP服务器 setpref( 'Internet' , 'SMTP_Username' ,MailAddress); setpref( 'Internet' , 'SMTP_Password' ,password); props = java.lang.System.getProperties; props.setProperty( 'mail.smtp.auth' , 'true' );  %sendmail(to, subject, content);   % 举个例子,比如想把前面运行得到精确度数据发送给程序员 accuracy=0.888;  % 收件人 receiver='[email protected]';  % 邮件标题 mailtitle='pattern recognition'; % 邮件内容 mailcontent=['mission compeleted! ',... 'accuracy=',num2str(accuracy)]; % 发送 sendmail(receiver, mailtitle, mailcontent); 复制代码

  为了以后方便使用,可以包装成一个函数:

复制代码 1 2 3 4 5 6 7 8 9 10 function mailTome(subject,content) MailAddress =  '[email protected]' ; password =  'X' ;   setpref( 'Internet' , 'E_mail' ,MailAddress); setpref( 'Internet' , 'SMTP_Server' , 'smtp.126.com' ); setpref( 'Internet' , 'SMTP_Username' ,MailAddress); setpref( 'Internet' , 'SMTP_Password' ,password); props = java.lang.System.getProperties; props.setProperty( 'mail.smtp.auth' , 'true' ); sendmail( 'X' ,subject,content); end 复制代码

  得到mail2me这个函数之后,只要在程序后面加上一句类似的: 

mailTome('Program Over','**** Program has finished');

真的没有问题了么?程序员的思想总是接近完备的。  函数中存在个人隐私(手机号码和密码),如果被人看到然后用来捉弄你就不好了。 MATLAB也是完备的,她提供了一种很好的内容保护机制: protected-code。   Command Window 键入: 

1 pcode mailTome

  然后删除mail2me.m。在此之后,再次输入: 

1 mailTome( 'Is OK?' , '见证奇迹的时刻到了' );

  从此,再也不会有第二个人知道你这个函数里面的内容了.

转载地址:http://www.cnblogs.com/ywl925/p/3574011.html



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3