{"id":1400,"date":"2016-01-29T14:37:23","date_gmt":"2016-01-29T19:37:23","guid":{"rendered":"http:\/\/xlinesoft.com\/blog\/?p=1400"},"modified":"2017-02-13T15:25:16","modified_gmt":"2017-02-13T20:25:16","slug":"massmailer-template-use-case","status":"publish","type":"post","link":"https:\/\/xlinesoft.com\/blog\/2016\/01\/29\/massmailer-template-use-case\/","title":{"rendered":"MassMailer template use case"},"content":{"rendered":"<blockquote><p><a href=\"http:\/\/xlinesoft.com\/massmailer\">MassMailer<\/a> template v2 was updated. This is a free upgrade for existing MassMailer template v2 owners. <a href=\"http:\/\/xlinesoft.com\/massmailer\">More info<\/a>. <\/p><\/blockquote>\n<p>MassMailer template can be used for more than just sending bulk emails. Lets consider the case where you manage a table with usernames and passwords for your internal company application. For increased security users should change passwords every 60 days. As an administrator you need to perform two standard tasks:<\/p>\n<ol>\n<li>Set reminders to users  when their password is about to expire<\/li>\n<li>Mark their account as inactive when password expires<\/li>\n<\/ol>\n<p>We&#8217;ll show how this can be done with the help of MassMailer template. In this example we&#8217;ll be using MySQL and here is how our table with logins and passwords looks. Only users where &#8216;active&#8217; field equals 1 are able to logon. <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/xlinesoft.com\/blog\/wp-content\/uploads\/2016\/01\/scr1.png\" alt=\"\" title=\"scr\" width=\"588\" height=\"155\" class=\"alignnone size-full wp-image-1401\" srcset=\"https:\/\/xlinesoft.com\/blog\/wp-content\/uploads\/2016\/01\/scr1.png 588w, https:\/\/xlinesoft.com\/blog\/wp-content\/uploads\/2016\/01\/scr1-300x79.png 300w, https:\/\/xlinesoft.com\/blog\/wp-content\/uploads\/2016\/01\/scr1-150x39.png 150w, https:\/\/xlinesoft.com\/blog\/wp-content\/uploads\/2016\/01\/scr1-400x105.png 400w\" sizes=\"auto, (max-width: 588px) 100vw, 588px\" \/><!--more--><\/p>\n<h2>1. Send a reminder two days before password expires<\/h2>\n<p>This is fairly straightforward. Here is the SQL query we can use:<\/p>\n<pre name=\"code\" class=\"sql:nocontrols\">select * from login where DATEDIFF(expires, now())=2<\/pre>\n<p>Assuming that today is January 29th, 2016 this query returns one record (dave.p). We can setup this task to run once a day and Dave.P will receive a nice &#8220;do not forget to change your password&#8221; reminder.<\/p>\n<p>Please note that this SQL query syntax is MySQL specific. Refer to <a href=\"http:\/\/xlinesoft.com\/blog\/2014\/11\/12\/datetime-handling-in-web-applications\/\">Date\/time handling in web applications<\/a> article for other databases syntax. <\/p>\n<h2>2. Make login expire<\/h2>\n<p>This one is more interesting. This task is going to also run once a day and change &#8216;active&#8217; column for those accounts that expire today to 0. <\/p>\n<p>SQL Query is very similar:<\/p>\n<pre name=\"code\" class=\"sql:nocontrols\">select * from login where DATEDIFF(expires, now())=0<\/pre>\n<p>Email body will say something like this:<\/p>\n<pre>Dear %username%\r\n\r\nYour account has expired. Call administrator at 1-800-XXX-XXXX in order to restore your access.\r\n<\/pre>\n<p>This is what we going to put into &#8216;Execute SQL query after email sent&#8217; field<\/p>\n<pre name=\"code\" class=\"sql:nocontrols\">\r\nupdate login set active=0 where id = %main.id%\r\n<\/pre>\n<p>This is it. Now we have two tasks that take care of sending reminders and marking accounts as expired. In real life you may want to send more reminders or do something more sophisticated than make your users call system admin when their accounts expires. <\/p>\n<p>Happy coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MassMailer template v2 was updated. This is a free upgrade for existing MassMailer template v2 owners. More info. MassMailer template can be used for more than just sending bulk emails. Lets consider the case where you manage a table with usernames and passwords for your internal company application. For increased security users should change passwords every 60 days. As an administrator you need to perform two standard tasks: Set reminders to users when their password is about to expire Mark their account as inactive when&#8230;<span class=\"clearfix clearfix-post\"><\/span><a href=\"https:\/\/xlinesoft.com\/blog\/2016\/01\/29\/massmailer-template-use-case\/\" class=\"more-link\">Continue Reading <span class=\"screen-reader-text\">&#8220;MassMailer template use case&#8221;<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,10,1,8],"tags":[],"class_list":["post-1400","post","type-post","status-publish","format-standard","hentry","category-asp-net","category-news","category-php-category","category-tutorials"],"_links":{"self":[{"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/posts\/1400","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/comments?post=1400"}],"version-history":[{"count":8,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/posts\/1400\/revisions"}],"predecessor-version":[{"id":1618,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/posts\/1400\/revisions\/1618"}],"wp:attachment":[{"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/media?parent=1400"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/categories?post=1400"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/tags?post=1400"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}