{"id":930,"date":"2013-03-17T00:56:57","date_gmt":"2013-03-17T03:56:57","guid":{"rendered":"http:\/\/www.jgarces.info\/mails-with-mailx\/"},"modified":"2013-09-10T00:54:52","modified_gmt":"2013-09-10T03:54:52","slug":"mails-with-mailx","status":"publish","type":"post","link":"https:\/\/www.jgarces.info\/en\/mails-with-mailx\/","title":{"rendered":"Mails with mailx"},"content":{"rendered":"<p>With this function you can send mails using mailx command.<\/p>\n<pre lang=\"shell\">\r\n#!\/bin\/sh\r\n\r\nsend_email()\r\n{\r\n  #\r\n  # Proceso de par\u00e1metros\r\n  #\r\n  DIRECCION=\"$1\"\r\n  ASUNTO=\"\"\r\n  MENSAJE=\"\"\r\n  if [ $# -ge 2 ]; then\r\n    if [ \"$2\" != \"-\" ]; then\r\n      ASUNTO=\"$2\"\r\n    fi\r\n  fi\r\n  if [ $# -ge 3 ]; then\r\n    if [ \"$3\" != \"-\" ]; then\r\n      MENSAJE=\"$3\"\r\n    fi\r\n  fi\r\n  ADJUNTO=\"\"\r\n  if [ $# -ge 4 ]; then\r\n    if [ \"$4\" != \"-\" ]; then\r\n      ADJUNTO=\"$4\"\r\n    fi\r\n  fi\r\n  #\r\n  # Env\u00edo del email\r\n  #\r\n  ( echo \"$MENSAJE\";\r\n    if [ \"$ADJUNTO\" != \"\" ]; then\r\n      archivo=`echo $ADJUNTO|cut -d'~' -f1`\r\n      nombre=`echo $ADJUNTO|cut -d'~' -f2`\r\n      if [[ \"$archivo\" == \"$nombre\" || \"$nombre\" == \"\" ]]; then\r\n        nombre=`basename $archivo`\r\n      fi\r\n      if [ -f \"$archivo\" ]; then\r\n        uuencode \"$archivo\" \"$nombre\";\r\n      fi\r\n    fi;\r\n  ) |  mailx -s \"$ASUNTO\" \"$DIRECCION\"\r\n}\r\n\r\nsend_email \"yourmail@yourdomain.com\" \"Subject\" \"Message body\" \"attachment.txt\"\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>With this function you can send mails using mailx command. #!\/bin\/sh send_email() { # # Proceso de par\u00e1metros # DIRECCION=&#8221;$1&#8243; ASUNTO=&#8221;&#8221; MENSAJE=&#8221;&#8221; if [ $# -ge 2 ]; then if [ &#8220;$2&#8221; != &#8220;-&#8221; ]; then ASUNTO=&#8221;$2&#8243; fi fi if [ $# -ge 3 ]; then if [ &#8220;$3&#8221; != &#8220;-&#8221; ]; then MENSAJE=&#8221;$3&#8243; fi [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[48,49,47],"class_list":["post-930","post","type-post","status-publish","format-standard","hentry","category-shell-script-en","tag-linux-en","tag-mailx-en","tag-sh-en"],"_links":{"self":[{"href":"https:\/\/www.jgarces.info\/en\/wp-json\/wp\/v2\/posts\/930","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jgarces.info\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jgarces.info\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jgarces.info\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jgarces.info\/en\/wp-json\/wp\/v2\/comments?post=930"}],"version-history":[{"count":1,"href":"https:\/\/www.jgarces.info\/en\/wp-json\/wp\/v2\/posts\/930\/revisions"}],"predecessor-version":[{"id":947,"href":"https:\/\/www.jgarces.info\/en\/wp-json\/wp\/v2\/posts\/930\/revisions\/947"}],"wp:attachment":[{"href":"https:\/\/www.jgarces.info\/en\/wp-json\/wp\/v2\/media?parent=930"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jgarces.info\/en\/wp-json\/wp\/v2\/categories?post=930"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jgarces.info\/en\/wp-json\/wp\/v2\/tags?post=930"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}