Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过MATLAB发送文本_Matlab_Email_Sms - Fatal编程技术网

通过MATLAB发送文本

通过MATLAB发送文本,matlab,email,sms,Matlab,Email,Sms,我试图使用以下脚本发送文本: 但我得到了一个错误: Error using sendmail (line 171) Authentication failed. Error in send_text_message (line 78) sendmail(emailto,subject,message) 即使我在脚本上有正确的电子邮件和密码。是否有人知道正在发生什么或能够使用此脚本 作为参考,以下是完整的脚本: function send_text_message(number,carrie

我试图使用以下脚本发送文本:

但我得到了一个错误:

Error using sendmail (line 171)
Authentication failed.

Error in send_text_message (line 78)
sendmail(emailto,subject,message)
即使我在脚本上有正确的电子邮件和密码。是否有人知道正在发生什么或能够使用此脚本

作为参考,以下是完整的脚本:

function send_text_message(number,carrier,subject,message)
% SEND_TEXT_MESSAGE send text message to cell phone or other mobile device.
%    SEND_TEXT_MESSAGE(NUMBER,CARRIER,SUBJECT,MESSAGE) sends a text message
%    to mobile devices in USA. NUMBER is your 10-digit cell phone number.
%    CARRIER is your cell phone service provider, which can be one of the
%    following: 'Alltel', 'AT&T', 'Boost', 'Cingular', 'Cingular2',
%    'Nextel', 'Sprint', 'T-Mobile', 'Verizon', or 'Virgin'. SUBJECT is the
%    subject of the message, and MESSAGE is the content of the message to
%    send.
% 
%    Example:
%      send_text_message('234-567-8910','Cingular', ...
%         'Calculation Done','Don't forget to retrieve your result file')
%      send_text_message('234-567-8910','Cingular', ...
%         'This is a text message without subject')
%
%   See also SENDMAIL.
%
% You must modify the first two lines of the code (code inside the double 
% lines) before using.

% Ke Feng, Sept. 2007
% Please send comments to: jnfengke@gmail.com
% $Revision: 1.0.0.0 $  $Date: 2007/09/28 16:23:26 $

% =========================================================================
% YOU NEED TO TYPE IN YOUR OWN EMAIL AND PASSWORDS:
mail = 'my@gmail.com';    %Your GMail email address
password = 'my_password';          %Your GMail password
% =========================================================================

if nargin == 3
    message = subject;
    subject = '';
end

% Format the phone number to 10 digit without dashes
number = strrep(number, '-', '');
if length(number) == 11 && number(1) == '1';
    number = number(2:11);
end

% Information found from
% http://www.sms411.net/2006/07/how-to-send-email-to-phone.html
switch strrep(strrep(lower(carrier),'-',''),'&','')
    case 'alltel';    emailto = strcat(number,'@message.alltel.com');
    case 'att';       emailto = strcat(number,'@mmode.com');
    case 'boost';     emailto = strcat(number,'@myboostmobile.com');
    case 'cingular';  emailto = strcat(number,'@cingularme.com');
    case 'cingular2'; emailto = strcat(number,'@mobile.mycingular.com');
    case 'nextel';    emailto = strcat(number,'@messaging.nextel.com');
    case 'sprint';    emailto = strcat(number,'@messaging.sprintpcs.com');
    case 'tmobile';   emailto = strcat(number,'@tmomail.net');
    case 'verizon';   emailto = strcat(number,'@vtext.com');
    case 'virgin';    emailto = strcat(number,'@vmobl.com');
end

%% Set up Gmail SMTP service.
% Note: following code found from
% http://www.mathworks.com/support/solutions/data/1-3PRRDV.html
% If you have your own SMTP server, replace it with yours.

% Then this code will set up the preferences properly:
setpref('Internet','E_mail',mail);
setpref('Internet','SMTP_Server','smtp.gmail.com');
setpref('Internet','SMTP_Username',mail);
setpref('Internet','SMTP_Password',password);

% The following four lines are necessary only if you are using GMail as
% your SMTP server. Delete these lines wif you are using your own SMTP
% server.
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');

%% Send the email
sendmail(emailto,subject,message)

if strcmp(mail,'matlabsendtextmessage@gmail.com')
    disp('Please provide your own gmail for security reasons.')
    disp('You can do that by modifying the first two lines of the code')
    disp('after the bulky comments.')
end

我以前遇到过这个问题,所以我可以为您提供解决方案:默认情况下,GMail会限制一些“不太安全”的登录,但您可以将其关闭,以便MATLAB可以登录(注意,您使您的帐户更容易受到攻击)

从Gmail开始

“设置”->“帐户和导入”->链接到“其他谷歌帐户设置”->“登录和安全”->“连接的应用程序和网站”->“允许不太安全的应用程序:打开”

看起来像这样。。。将其更改为“开”:

我以前遇到过这个问题,所以我可能会为您提供解决方案:默认情况下,GMail会限制一些“不太安全”的登录,但您可以关闭它,以便MATLAB可以登录(注意,您使您的帐户更易受攻击)

从Gmail开始

“设置”->“帐户和导入”->链接到“其他谷歌帐户设置”->“登录和安全”->“连接的应用程序和网站”->“允许不太安全的应用程序:打开”

看起来像这样。。。将其更改为“开”:

您可能应该在从中获取代码的MathWorks FEX页面上为作者留言。他们比我们更有能力帮助您。您可能应该在MathWorks FEX页面上给作者留言,您可以从中获得代码。他们比我们更有能力帮助你。