{"id":169,"date":"2008-03-13T07:17:42","date_gmt":"2008-03-13T12:17:42","guid":{"rendered":"http:\/\/www.tigoe.net\/pcomp\/code\/category\/code\/processing\/169"},"modified":"2008-03-13T07:17:42","modified_gmt":"2008-03-13T12:17:42","slug":"sending-mail-from-processing","status":"publish","type":"post","link":"https:\/\/www.tigoe.com\/pcomp\/code\/Processing\/169\/","title":{"rendered":"Sending Mail from Processing"},"content":{"rendered":"<p>Here&#8217;s a piece of code to send mail from Processing.  It uses the net library.  Warning: your mail server may not use port 25.<\/p>\n<pre>\r\n\/* mail_client\r\n by Tom Igoe\r\n \r\n  A simple mail sender client\r\n Created 21 January 2006\r\n *\/\r\n\r\nimport processing.net.*; \r\nClient myClient; \r\nint clicks;\r\nString reply = null;\r\nboolean sent = false;\r\nvoid setup() { \r\n  \/\/ Connect:\r\n  myClient = new Client(this, \"echonyc.com\", 25); \r\n  delay(300);\r\n\r\n} \r\n\r\n\r\nvoid draw() { \r\n  if(!sent) {\r\n    waitForReply();\r\n    myClient.write(\"HELO echonyc.com&#92;n\");\r\n    waitForReply();\r\n    myClient.write(\"MAIL FROM:tigoe@echonyc.com&#92;n\");\r\n    waitForReply();\r\n    myClient.write(\"RCPT TO:tigoe@echonyc.com&#92;n\");\r\n    waitForReply();\r\n    myClient.write(\"DATA&#92;n\");\r\n    waitForReply();\r\n    myClient.write(\"Subject:Noodles&#92;n\");\r\n    myClient.write(\"From:tigoe@echonyc.com&#92;n\");\r\n    myClient.write(\"To:tigoe@tigoe.net&#92;n\");\r\n    myClient.write(\"&#92;rHere's the body&#92;n.&#92;n\");\r\n    waitForReply();\r\n    myClient.write(\"QUIT&#92;n&#92;r\");\r\n    waitForReply();\r\n  }\r\n  sent = true;\r\n} \r\n\r\n\r\nvoid waitForReply() {\r\n  int newChar = 0;\r\n  while (newChar != 10) {\r\n    if(myClient.available() > 0) {\r\n      newChar = myClient.read();\r\n      reply += (char)newChar;\r\n    }\r\n  }\r\n  println(reply); \r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s a piece of code to send mail from Processing. It uses the net library. Warning: your mail server may not use port 25. \/* mail_client by Tom Igoe A simple mail sender client Created 21 January 2006 *\/ import processing.net.*; Client myClient; int clicks; String reply = null; boolean sent = false; void setup() &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.tigoe.com\/pcomp\/code\/Processing\/169\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Sending Mail from Processing&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-169","post","type-post","status-publish","format-standard","hentry","category-Processing"],"_links":{"self":[{"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/posts\/169","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/comments?post=169"}],"version-history":[{"count":0,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/posts\/169\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/media?parent=169"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/categories?post=169"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/tags?post=169"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}