CentOS 6.3下使用smtp以及Django 1.4.1发送邮件例子
mail -s “邮件主题”abc@gmail.com < "邮件内容"
使用Django在进行邮件发送
来源:http://blog.csdn.net/willierstrong/article/details/8204794
from django.core.mail import send_mail, BadHeaderError from django.http import HttpResponseRedirect def send_email(request): subject = request.POST.get('subject', 'this is subject') #发送的邮件主题 message = request.POST.get('message', 'it \'s time to go home') #发送的消息 from_email = request.POST.get('from_email', '******') #发件人邮箱 to_email = request.POST.get('to_email', '××××××') #收件人的邮箱 if subject and message and from_email: try: send_mail(subject, message, from_email, [to_email]) #最后一个参数是收件人列表,可发送至多人 except BadHeaderError: return HttpResponse('Invalid header found.') return HttpResponseRedirect('/buy/') else: # In reality we'd use a form class # to get proper validation errors. return HttpResponse('Make sure all fields are entered and valid.')