Exemplo n.º 1
0
def sendContactUsEmail(request):
    strUserEmail = request.session.get("logined_user_email", None)
    if strUserEmail:
        #確定已登入
        pass
    else:
        #未登入
        strUserEmail = request.POST.get("user_email", "")
    strMsgTitle = request.POST.get("message_title", "")
    strMsgContent = request.POST.get("message_content", "")
    print(strUserEmail, strMsgTitle, strMsgContent)
    strMsg = (
        "<h2>FFT Message from %s,</h2>"
        "<h3>%s</h3>"
        "<div>"
        "%s"
        "</div>"%(strUserEmail, strMsgTitle, strMsgContent)
    )
    #寄出 email
    emailUtil = EmailUtility()
    emailUtil.sendEmail(
        strSubject="FFT Message from user: %s"%strUserEmail,
        strFrom=strUserEmail,
        strTo="me",
        strMsg=strMsg,
        lstStrTarget=["*****@*****.**"],
        strSmtp="smtp.gmail.com:587",
        strAccount="*****@*****.**",
        strPassword="******"
    )
    return JsonResponse({"contact_status":"ok"}, safe=False)
Exemplo n.º 2
0
def sendEmailVerification(request):
    strUserEmail = request.session.get("logined_user_email", None)
    if strUserEmail:
        #確定已登入 生成 Email 認證信
        #產生 UUID
        strUUID = str(uuid.uuid1())
        #儲存認證資訊
        Verification.objects.update_or_create(
            strEmail = strUserEmail,
            defaults = {
                "dtValidTime": timezone.now() + timezone.timedelta(days=1),#click email in 1 day
                "strUUID": strUUID
            }
        )
        strMsg = (
            "<div><img src=\"http://www.findfinetour.com/static/img/logo.png\" width=\"80\"/></div>"
            "<h2>Dear %s,</h2>"
            "<div>"
                "<p>Welcome to FindFineTour, the biggest meta search website for local tour in the world.</p>"
                "<p>Please click this "
                    "<a href=\"http://www.findfinetour.com/account/verifyEmail?strEmail=%s&strUUID=%s\">"
                        "link"
                    "</a>"
                " to confirm your registration.</p>"
                "<p>Start to find more interesting local tours on FindFineTour!</p>"
                "<p>Let's go for a new trip with your friends/family!</p>"
                "<p><a href=\"http://www.findfinetour.com\">http://www.findfinetour.com</a></p>"
                "<p>Your Travel Secretary,</p>"
                "<p>FindFineTour</p>"
            "</div>"%(strUserEmail, strUserEmail, strUUID)
        )
        #寄出 email
        emailUtil = EmailUtility()
        emailUtil.sendEmail(
            strSubject="user email verification.",
            strFrom="FindFineTour",
            strTo="me",
            strMsg=strMsg,
            lstStrTarget=[strUserEmail],
            strSmtp="smtp.gmail.com:587",
            strAccount="*****@*****.**",
            strPassword="******"
        )
    return redirect("/account/userinfo")
Exemplo n.º 3
0
class EmailUtilityTest(unittest.TestCase):

    # 準備
    def setUp(self):
        logging.basicConfig(level=logging.INFO)
        self.emailUtil = EmailUtility()

    # 收尾
    def tearDown(self):
        pass

    # 測試 寄信
    def test_sendEmail(self):
        logging.info("EmailUtilityTest.test_sendEmail")
        self.emailUtil.sendEmail(
            strSubject="unittest:bennu",
            strFrom="public.muchu1983",
            strTo="me",
            strMsg="內容:許公蓋",
            lstStrTarget=["*****@*****.**"],
            strSmtp="smtp.gmail.com:587",
            strAccount="*****@*****.**",
            strPassword="******",
        )
Exemplo n.º 4
0
 def setUp(self):
     logging.basicConfig(level=logging.INFO)
     self.emailUtil = EmailUtility()