サイト用のカスタム招待アプリを作成しました。招待を有効にするには、メールに送信されたリンクに従う必要があります。
問題は、私のメール送信機能で、次のようなメッセージとして文字列を送信する際に問題が発生することです。
custom_message = "http://www.something.com%s" % invite.get_absolute_url()
多数のテストの後、問題は に関係している:
ようです。
全体を省略できるので、コロンは必要ありませんhttp://
。send_custom_email()
しかし、この文字列を関数に渡すときに関数が機能しないのはなぜですか
参考までに、これは私のメール送信機能です。
def send_custom_email(recipient, custom_message):
to = recipient
gmail_user = 'someone@gmail.com'
gmail_pwd = GMAIL_PWD
smtpserver = smtplib.SMTP("smtp.gmail.com",587)
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.ehlo
smtpserver.login(gmail_user, gmail_pwd)
header = 'To:' + to + '\n' + 'From: ' + gmail_user + '\n' + 'Subject:Invite Link \n'
print header
unicoded_custom_message = unicode(custom_message)
msg = header + unicoded_custom_message
smtpserver.sendmail(gmail_user, to, msg)
print 'done!'
smtpserver.close()
テスト:
>>> custom_message ="http://www.somesite.com%s"
>>> send_custom_email(recipient='someotherperson@mailinator.com', custom_message=custom_message)
To:someone@mailinator.com
From: someotherperson@gmail.com
Subject:Invite Link
done!
メールは送信されますが、メッセージが表示されません