{"id":245,"date":"2010-09-16T18:43:16","date_gmt":"2010-09-16T18:43:16","guid":{"rendered":"https:\/\/blogs.mathworks.com\/loren\/2010\/09\/16\/my-first-use-of-sendmail\/"},"modified":"2016-08-04T09:20:16","modified_gmt":"2016-08-04T14:20:16","slug":"my-first-use-of-sendmail","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/loren\/2010\/09\/16\/my-first-use-of-sendmail\/","title":{"rendered":"My First Use of sendmail"},"content":{"rendered":"<div class=\"content\">\r\n\r\nToday I was working on a demo that someone else started. And then, wouldn't you know, I hit a snag. I decided that now was\r\nthe time to learn to use <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/ref\/sendmail.html\"><tt>sendmail<\/tt><\/a> so I could send my version of code right from my MATLAB session. It was so easy, I thought I'd show you how to do it.\r\n\r\n&nbsp;\r\n<h3>Contents<\/h3>\r\n<div>\r\n<ul>\r\n \t<li><a href=\"#1\">Set Preferences<\/a><\/li>\r\n \t<li><a href=\"#3\">In Business!<\/a><\/li>\r\n \t<li><a href=\"#4\">Do You Use sendmail?<\/a><\/li>\r\n<\/ul>\r\n<\/div>\r\n<h3>Set Preferences<a name=\"1\"><\/a><\/h3>\r\nI first tried using <tt>sendmail<\/tt> without reading <b>all<\/b> of the doc, just the input argument list. And I got an error telling me I had to use <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/ref\/setpref.html\"><tt>setpref<\/tt><\/a> to set MATLAB up to know about my internet presence. The first error message showed that I had to set up information about\r\nmy email account.\r\n<pre>       setpref('Internet','E_mail','xxx@company.com')<\/pre>\r\nI tried sending the message again, and got prompted with a second error, so decided to read the reference page so I would\r\nbypass any other errors as well. Turned out, that wasn't necessary. I fixed my preferences again to set up information about\r\nthe mail server.\r\n<pre>       setpref('Internet','SMTP_Server','mail')<\/pre>\r\n<h3>In Business!<a name=\"3\"><\/a><\/h3>\r\nNow I was in business and able to send the MATLAB code to my co-worker without leaving MATLAB.\r\n<pre>       sendmail('yyy@company.com','demo files', ...\r\n                'loren''s version','mydemo.m')<\/pre>\r\n<h3>Do You Use sendmail?<a name=\"4\"><\/a><\/h3>\r\nI can imagine setting up a long simulation and sending my self email to let me know when it's done, especially if I am doing\r\nso during the evening or weekend. What tasks do you use <tt>sendmail<\/tt> for? \r\n\r\n<script>\/\/ <![CDATA[\r\nfunction grabCode_78f251b75a6d4dc69f354b05dd1c0795() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='78f251b75a6d4dc69f354b05dd1c0795 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 78f251b75a6d4dc69f354b05dd1c0795';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        author = 'Loren Shure';\r\n        copyright = 'Copyright 2010 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('\r\n\r\n<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\r\n\r\n\r\n\\n');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }\r\n\/\/ ]]><\/script>\r\n<p style=\"text-align: right; font-size: xx-small; font-weight: lighter; font-style: italic; color: gray;\">\r\n<a><span style=\"font-size: x-small; font-style: italic;\">Get\r\nthe MATLAB code\r\n<noscript>(requires JavaScript)<\/noscript><\/span><\/a>\r\n\r\nPublished with MATLAB\u00ae 7.11<\/p>\r\n\r\n<\/div>\r\n<!--\r\n78f251b75a6d4dc69f354b05dd1c0795 ##### SOURCE BEGIN #####\r\n%% My First Use of sendmail\r\n% Today I was working on a demo that someone else started.  And then,\r\n% wouldn't you know, I hit a snag.  I decided that now was the time to\r\n% learn to use\r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/ref\/sendmail.html % |sendmail|> so I could send my version of code right from my MATLAB\r\n% session.  It was so easy, I thought I'd show you how to do it.\r\n%% Set Preferences\r\n% I first tried using |sendmail| without reading *all* of the doc, just the\r\n% input argument list.  And I got an error telling me I had to use\r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2010b\/techdoc\/ref\/setpref.html % |setpref|> to set MATLAB up to know about my internet presence.  The\r\n% first error message showed that I had to set up information about my\r\n% email account.\r\n%\r\n%         setpref('Internet','E_mail','xxx@company.com')\r\n%%\r\n% I tried sending the message again, and got prompted with a second error,\r\n% so decided to read the reference page so I would bypass any other errors\r\n% as well. Turned out, that wasn't necessary.  I fixed my preferences again\r\n% to set up information about the mail server.\r\n%\r\n%         setpref('Internet','SMTP_Server','mail')\r\n%% In Business!\r\n% Now I was in business and able to send the MATLAB code to my co-worker\r\n% without leaving MATLAB.\r\n%\r\n%         sendmail('yyy@company.com','demo files', ...\r\n%                  'loren''s version','mydemo.m')\r\n%% Do You Use sendmail?\r\n% I can imagine setting up a long simulation and sending my self email to\r\n% let me know when it's done, especially if I am doing so during the\r\n% evening or weekend.  What tasks do you use |sendmail| for?  Let me know\r\n% <https:\/\/blogs.mathworks.com\/?p=245#respond here>.\r\n\r\n##### SOURCE END ##### 78f251b75a6d4dc69f354b05dd1c0795\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n\r\nToday I was working on a demo that someone else started. And then, wouldn't you know, I hit a snag. I decided that now was\r\nthe time to learn to use sendmail so I could send my version of code... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/loren\/2010\/09\/16\/my-first-use-of-sendmail\/\">read more >><\/a><\/p>","protected":false},"author":39,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[13],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/245"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/users\/39"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/comments?post=245"}],"version-history":[{"count":2,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/245\/revisions"}],"predecessor-version":[{"id":1973,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/245\/revisions\/1973"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/media?parent=245"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/categories?post=245"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/tags?post=245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}