{"id":835,"date":"2022-12-31T14:07:41","date_gmt":"2022-12-31T13:07:41","guid":{"rendered":"http:\/\/www.zerfallskonstante.de\/?p=835"},"modified":"2022-12-31T14:07:41","modified_gmt":"2022-12-31T13:07:41","slug":"ssmtp-skript","status":"publish","type":"post","link":"https:\/\/www.zerfallskonstante.de\/?p=835","title":{"rendered":"ssmtp skript"},"content":{"rendered":"<p><code><br \/>\n#!\/bin\/bash<\/p>\n<p># Set the email address to use for sending emails<br \/>\nEMAIL_ADDRESS=\"user@example.com\"<\/p>\n<p># Set the list of passwords to try when sending emails<br \/>\nPASSWORDS=(password1 password2 password3)<\/p>\n<p># Set the SMTP server and port to use for sending emails<br \/>\nSMTP_SERVER=\"smtp.example.com\"<br \/>\nSMTP_PORT=587<\/p>\n<p># Set the recipients of the email<br \/>\nRECIPIENTS=\"recipient1@example.com recipient2@example.com\"<\/p>\n<p># Set the subject and message body of the email<br \/>\nSUBJECT=\"Example Email\"<br \/>\nMESSAGE=\"This is an example email sent using ssmtp\"<\/p>\n<p># Loop through the list of passwords, trying each one until the email is successfully sent<br \/>\nfor password in \"${PASSWORDS[@]}\"; do<br \/>\n    # Set the password for the current iteration<br \/>\n    echo \"AuthUser=$EMAIL_ADDRESS\" > ~\/.ssmtp\/ssmtp.conf<br \/>\n    echo \"AuthPass=$password\" >> ~\/.ssmtp\/ssmtp.conf<br \/>\n    echo \"mailhub=$SMTP_SERVER:$SMTP_PORT\" >> ~\/.ssmtp\/ssmtp.conf<br \/>\n    echo \"UseSTARTTLS=YES\" >> ~\/.ssmtp\/ssmtp.conf<\/p>\n<p>    # Send the email and store the output in a variable<br \/>\n    EMAIL_OUTPUT=$(echo -e \"To: $RECIPIENTS\\nSubject: $SUBJECT\\n\\n$MESSAGE\" | ssmtp $RECIPIENTS)<\/p>\n<p>    # Check if the email was successfully sent<br \/>\n    if [[ $EMAIL_OUTPUT == *\"250 2.0.0 OK\"* ]]; then<br \/>\n        # Email was successfully sent<br \/>\n        break<br \/>\n    else<br \/>\n        # Email was not successfully sent, try the next password<br \/>\n        continue<br \/>\n    fi<br \/>\ndone<\/p>\n<p># Check if the email was successfully sent with any of the passwords<br \/>\nif [[ $EMAIL_OUTPUT != *\"250 2.0.0 OK\"* ]]; then<br \/>\n    # Email was not successfully sent with any of the passwords<br \/>\n    echo \"Error: Failed to send email with any of the provided passwords\"<br \/>\nelse<br \/>\n    # Email was successfully sent<br \/>\n    echo \"Success: Email was sent successfully\"<br \/>\nfi<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>#!\/bin\/bash # Set the email address to use for sending emails EMAIL_ADDRESS=&#8220;user@example.com&#8220; # Set the list of passwords to try when sending emails PASSWORDS=(password1 password2 password3) # Set the SMTP server and port to use for sending emails SMTP_SERVER=&#8220;smtp.example.com&#8220; SMTP_PORT=587 &hellip; <a href=\"https:\/\/www.zerfallskonstante.de\/?p=835\">Weiterlesen <span class=\"meta-nav\">&rarr;<\/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":[12,9],"tags":[],"class_list":["post-835","post","type-post","status-publish","format-standard","hentry","category-bash","category-linux"],"_links":{"self":[{"href":"https:\/\/www.zerfallskonstante.de\/index.php?rest_route=\/wp\/v2\/posts\/835","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zerfallskonstante.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zerfallskonstante.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zerfallskonstante.de\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zerfallskonstante.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=835"}],"version-history":[{"count":1,"href":"https:\/\/www.zerfallskonstante.de\/index.php?rest_route=\/wp\/v2\/posts\/835\/revisions"}],"predecessor-version":[{"id":836,"href":"https:\/\/www.zerfallskonstante.de\/index.php?rest_route=\/wp\/v2\/posts\/835\/revisions\/836"}],"wp:attachment":[{"href":"https:\/\/www.zerfallskonstante.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=835"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zerfallskonstante.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=835"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zerfallskonstante.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=835"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}