2012-10-22 2 views
6

디버깅 방법조차 잘 모르겠습니다. 저는 장고에서 저의 의견 중 하나에서 send_mail을 사용하고 있습니다. 프로덕션 환경에서 사용하는 것과 동일한 SMTP 설정을 사용하여 로컬에서 응용 프로그램을 사용할 때 제대로 작동하며 프로덕션 환경에서 쉘에서 정상적으로 작동합니다 (다시 동일한 설정 사용). 그러나 실제로 프로덕션에서 앱을 사용하면 메시지가 전송되지 않습니다. 문제를 해결하는 방법을 알려주세요.Django의 Send_mail은 쉘에서 작동하며,보기가 아닌 로컬에서 작동합니다.

전체보기에는 붙여 넣지 않지만 여기에는 관련 섹션이 있습니다.

if request.method == 'POST': 
    message, form = decideform(request.POST) 
    if form.is_valid(): 
     invitation.status = form.cleaned_data['status'] 
     invitation.save() 
     message, form = decideform(request.POST) 
     update = 'Thank you for updating your status.' 

     # Send an email confirming their change 
     subject = 'Confirming your RSVP [%s %s]' % (invitation.user.first_name, invitation.user.last_name) 
     body = message + ' Remember, the URL to update or change your RSVP is http://the.url%s.' % invitation.get_absolute_url() 
     send_mail(subject, body, '[email protected]', ['[email protected]', invitation.user.email], fail_silently=True) 

그리고 여기에 보안을 위하여 변경 두드러진 세부 사항을, 내 local_settings에 파일에서 관련 비트입니다 :

EMAIL_HOST = 'mail.mydomain.com' 
EMAIL_PORT = 587 
EMAIL_USE_TLS = True 
EMAIL_HOST_USER = '[email protected]' 
DEFAULT_FROM_USER = '[email protected]' 
EMAIL_HOST_PASSWORD = 'p4ssw0rd' 
+3

안녕하세요. SO! 'fail_silently = False'를 사용하고'SMTPException'을 찾으셨습니까? –

+0

고맙습니다, 세자르! 나는 fail_silently 플래그를 (로컬로, 프로덕션 셸에서, 그리고 프로덕션 환경에서) False로 설정하여 시도했지만 어느 시점에서도 SMTPException을 발견하지 못했습니다. (프로덕션 환경의 앱이 해당 예외를 오류 로그에 기록한다고 가정합니다.) – mthomps

답변

0

권한을 확인합니다. send_mail을 실행할 수있는 권한이있을 수도 있지만 앱은 그렇지 않습니다.

0

동일한 문제가 있습니다. send_mail 인라인의 코드를 복사 삼년 후 : 그것을 고정하지만 당신은 대신-sendgrid 장고 시도 할 수 있습니다

 connection = django.core.mail.get_connection(username=None, password=None, fail_silently=False) 
     mail = django.core.mail.message.EmailMessage('hello', 'world', '[email protected]', ['[email protected]'],            connection=connection) 
     mail.send()    
0

같은 configure.Use 설정에 매우 쉽게하는 이유는 아직 모른다
EMAIL_BACKEND = "sgbackend.SendGridBackend" 
SENDGRID_USER = 'xxxxxx' 
SENDGRID_PASSWORD = 'xxxxxx' 
EMAIL_PORT = 1025 
관련 문제