To build a mail-sending server using Haraka

Source: Internet
Author: User
Tags sub domain subdomain

Install NPM install-g Haraka
Initialize Haraka-i/etc/haraka

DKIM configuration:

Cd/etc/haraka/dkim
SH dkim_key_gen.sh miantiao.me
DNS configuration: 1.SPF Related:
Add TXT Record
If the top-level domain name host name is null or @, if it is a subdomain, the host name is mail (modified according to your subdomain) value:
V=SPF1 ip4:49.74.15.209 ip4:192.168.199.219 ~all

Online test whether the SPF is successfully deployed: http://www.openspf.org/Why?show-form=1

2.DKIM Related:
Add TXT Record
If is the top-level domain name hostname is the host name is Mail._domainkey, if is the child domain name own host name is Mail._domainkey.mail (the second domain name changes your sub domain name)
Value: "v=dkim1;p=miibijanbgkqhkig9w0baqefaaocaq8amiibcgkcaqeaoweqne0b4albs9ih9uug8xto0pwo8u25487bnf8gqxbl6ca+ lnfvghc6addobufiep1ld6c/6ufq+mvab2pujyakqoxxnj20nhzrshbelwkuagd2gus5d+hcryhrcqxh1bguwxvhh9v4bk1a6i8mwil0snn+ sm0vuaoxwwumlewhvt7emxaqxmgstzidinwgxlw0tu+c+cgueye75bn42jsbyvfb2pykmh9ss57apdxgghukx+sdmjl3ztbhfuujr3vhwg+ Cqycij3yku9lkzxrrtnpayj1alv510z1exuzcwrjxxjqmnnd3a/9wkxphi8wiynfj4wqayzf74mrhrqidaqab "

Add User:

Cd/etc/haraka
Echo ' Auth/flat_file ' >> plugins
Vim Auth_flat_file.ini
#修改为 methods:
#methods =login
In the above file, the [users] group has an account on the left and a password on the right (customizable):

[Users]
Matt=test
Start Haraka:
Haraka-c/etc/haraka

Test:

#-*-Coding:utf-8-*-
Import Smtplib
From Email.mime.text import Mimetext

mailto_list=[' test@qq.com '] #收件地址
Mail_host= "127.0.0.1" #设置服务器
Mail_user= "Matt" #用户名
mail_pass= "Test" #口令
mail_postfix= "Miantiao.me" #发件箱的后缀

def send_mail (to_list,sub,content):
Me= "Haraka" + "<" +mail_user+ "@" +mail_postfix+ ">"
msg = Mimetext (content,_subtype= ' plain ', _charset= ' utf-8 ')
msg[' Subject ' = Sub
msg[' from ' = Me
Msg[' to '] = ";". Join (To_list)
Try
Server = Smtplib. SMTP ()
Server.connect (Mail_host)
Server.login (Mail_user,mail_pass)
Server.sendmail (Me, To_list, msg.as_string ())
Server.close ()
Return True
Except Exception, E:
Print str (e)
Return False
if __name__ = = ' __main__ ':
For mail in mailto_list:
If Send_mail ([mail], "test message title", "" "This is the test message" ""):
Print "Send Success"
Else
Print "Send Failed"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.