I have a simple Django contact form (user email, message). I had configured a Gmail server and it was working but it always rewrote the from address with the address listed in settings.py as pointed out by this answer as well. So I've configured my settings using a Yahoo Mail server instead.
Here is my settings.py file
EMAIL_HOST = 'smtp.mail.yahoo.com'
EMAIL_HOST_USER = 'myid@yahoo.com'
EMAIL_HOST_PASSWORD = 'mypass'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
Here is my views.py
def contact(request):
if request.method == 'POST':
form = ContactForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
send_mail(
'Contact Us',
cd['message'],
cd.get('email', ''),
['myid@yahoo.com'],
)
return HttpResponseRedirect('thanks')
else:
form = ContactForm()
return render(request, 'hunt/contact.html', {'form': form})
Now I'm getting a SMTPSenderRefused exception.
Exception value - (553, 'From address not verified - see http://help.yahoo.com/l/us/yahoo/mail/original/manage/sendfrom-07.html', 'someone@gmail.com')
EDIT - I tried putting my own id myid@yahoo.com in the Email field and it worked. It only seems to be working for my email id.