-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move send_test_email to email_utils.
This is a temporary hack because email_client.py view file was previously named email.py and because of lingering .pyc files, we run into import problems. I was unable to cleanup .pyc files as part of initrock or rpm spec file(oh, this only effects production style deployment not development) so the final approach is to amend the update_run to remove .pyc files(this will take effect in future) and move any code that imports email to a directory outside of views directory. with the update_run change in place, we can remove this temporary fix in a future update.
- Loading branch information
Showing
2 changed files
with
39 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
""" | ||
Copyright (c) 2012-2015 RockStor, Inc. <http://rockstor.com> | ||
This file is part of RockStor. | ||
RockStor is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published | ||
by the Free Software Foundation; either version 2 of the License, | ||
or (at your option) any later version. | ||
RockStor is distributed in the hope that it will be useful, but | ||
WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
""" | ||
|
||
#to be moved to views/email_client.py after an update or so. | ||
|
||
import smtplib | ||
from email.MIMEMultipart import MIMEMultipart | ||
from email.MIMEBase import MIMEBase | ||
from email.MIMEText import MIMEText | ||
from email.Utils import formatdate | ||
from email import Encoders | ||
|
||
def send_test_email(eco, subject): | ||
msg = MIMEMultipart() | ||
msg['From'] = eco.sender | ||
msg['To'] = eco.receiver | ||
msg['Date'] = formatdate(localtime=True) | ||
msg['Subject'] = subject | ||
|
||
msg.attach(MIMEText(subject)) | ||
smtp = smtplib.SMTP('localhost') | ||
smtp.sendmail(eco.sender, eco.receiver, msg.as_string()) | ||
smtp.close() |