private function get_headers($format = 'plain') { if (!$this->from) { $this->from = awpcp_admin_email_from(); } switch ($format) { case 'plain': $content_type = 'text/plain; charset="' . get_option('blog_charset') . '"'; break; case 'html': $content_type = 'text/html; charset="' . get_option('blog_charset') . '"'; break; } $headers = array_merge(array('MIME-Version' => '1.0', 'Content-Type' => $content_type, 'From' => $this->from, 'Reply-To' => awpcp_admin_email_to()), $this->headers); $email_headers = ''; foreach ($headers as $k => $v) { $email_headers .= sprintf("%s: %s\r\n", $k, $v); } return $email_headers; }
/** * Check if any Ad is about to expire and send an email to the poster. * * This functions runs daily. */ function awpcp_ad_renewal_email() { global $wpdb; if (!(get_awpcp_option('sent-ad-renew-email') == 1)) { return; } $notification = awpcp_listing_is_about_to_expire_notification(); $admin_sender_email = awpcp_admin_email_from(); foreach (awpcp_get_listings_about_to_expire() as $listing) { // When the user clicks the renew ad link, AWPCP uses // the is_about_to_expire() method to decide if the Ad // can be renewed. We double check here to make // sure users can use the link in the email immediately. if (!$listing->is_about_to_expire()) { continue; } $email = new AWPCP_Email(); $email->from = $admin_sender_email; $email->to = $listing->ad_contact_email; $email->subject = $notification->render_subject($listing); $email->body = $notification->render_body($listing); if ($email->send()) { $listing->renew_email_sent = true; $listing->save(); } } }