小编Luc*_*ike的帖子

如何通过代理发送django电子邮件与身份验证

我正在尝试从代理背后的工作PC发送电子邮件.

在settings.py中,我的代码如下所示:

    #email setup
    EMAIL_USE_TLS = True
    EMAIL_HOST = 'smtp.gmail.com'
    EMAIL_HOST_USER = 'username@gmail.com'
    EMAIL_HOST_PASSWORD = 'password'
    EMAIL_PORT = 587
Run Code Online (Sandbox Code Playgroud)

在views.py中:

    from django.core.mail import send_mail

    def home(request):
        context = RequestContext(request)
        send_mail('test email', 'hello world', 'sender@gmail.com', ['receiver@email.com'], fail_silently=False)
        return render_to_response('project/home.html', context)
Run Code Online (Sandbox Code Playgroud)

这给出了错误:

    [Errno 10061] No connection could be made because the target machine actively refused it
Run Code Online (Sandbox Code Playgroud)

如何使用代理实现身份验证?

python email django proxy

5
推荐指数
0
解决办法
613
查看次数

如何删除 Django 中 EmailField 上的占位符?

我正在使用 django-allauth 并创建了一个继承自 SignupForm 的自定义注册表单。如何从电子邮件字段中删除默认占位符?我不想要占位符。

from allauth.account.forms import SignupForm

class UserSignUpForm(SignupForm):
    first_name = forms.CharField(max_length=155)
    last_name = forms.CharField(max_length=155)
    mobile = forms.CharField(max_length=20)

    def __init__(self, *args, **kwargs):
        super(UserSignUpForm, self).__init__(*args, **kwargs)

        del self.fields['password1']
        del self.fields['password2']

        self.fields['first_name'].widget.attrs.update({
            'class': 'required form-control',
        })
        self.fields['last_name'].widget.attrs.update({
            'class': 'required form-control',
        })
        self.fields['email'].widget.attrs.update({
            'class': 'required email form-control',
        })
        self.fields['mobile'].widget.attrs.update({
            'class': 'required form-control',
        })

    def custom_signup(self, request, user):
        user.first_name = self.cleaned_data['first_name']
        user.last_name = self.cleaned_data['last_name']
        user.mobile_number = self.cleaned_data['mobile']
        user.save()
Run Code Online (Sandbox Code Playgroud)

forms django placeholder django-allauth

4
推荐指数
1
解决办法
2243
查看次数

标签 统计

django ×2

django-allauth ×1

email ×1

forms ×1

placeholder ×1

proxy ×1

python ×1