mutt + fetchmail + postfix 收发imap的邮件

mutt 是一个客户端,

postfix 用来发邮件

fetchmail 用来收邮件


收imap邮件的配置

.muttc

------------------------------------------

#set sendmail = "/usr/bin/msmtp -v -X ~/log/.msmtp.log"    # daemon to send mail
set beep = yes
set copy = yes
set fast_reply = yes                    # don't alter reply mail-addr and subject
set folder = ~/Mail                    #邮件存放目录
set include = yes                    #回信时是否包含原文
set mbox = "=inbox"               
set mbox_type = /var/spool/mail/richard            #~/Mail
set pager_context = 1
set pager_index_lines = 16
set pgp_verify_sig = no
set postponed = "=postponed"
set record = "=sent"
set locale = "zh_CN"
set sendmail_wait = 0
set status_on_top = no
set to_chars = "+TCEL"
set pager_stop
set editor = "vim"
set use_from = yes
set realname = "Richard Yang"
set from = [email protected]
set envelope_from=yes
mailboxes 'echo ~/Mail/*'
my_hdr From: Richard Yang<[email protected]>             #这俩行一定要写,否则你的信件会以
my_hdr Reply-To: Richard Yang<[email protected]>         #root@localhost这样的地址发送出去,
                                                       #你的发件服务器会拒绝发送!

set sort = threads                        
set sort_aux = date-sent

macro index G "!fetchmail -av"        #这俩行定义了热键G激活fetchmail来收邮件
macro pager G "!fetchmail -av"        #实际上我喜欢将fetchmail加入开机启动脚本


------------------------------------------



.fetchmailrc

------------------------------------------

# default settings for polling and logging
set postmaster "root"
set syslog
set daemon 20
set logfile "/home/richard/Mail/log"

# set your ltc imap account user id and password in these next lines
# and change localuser to match your Linux workstation login
poll imap.linux.xxx.com with proto IMAP auth cram-md5
username "xxx" with password "xxx" is "richard" here keep
sslproto none, no rewrite, no idle

# The 'sslproto none' option disables tls and ssl support. If you want to
# use tls encryption change 'none' to 'tls1'. See the fetchmail man
# page for a description of 'no rewrite' and 'no idle'. You may also wish
# to consider the options 'fetchall', 'keep', and 'nokeep'.

------------------------------------------


postfix 配置


A local MTA, such as postfix or sendmail, is used when you need to have your Linux system process outgoing mail. For example, if you are using mutt or pine which expect localhost to handle sending mail, you will need to configure an MTA. You do not need to configure a local MTA if you are using an email client like Thunderbird or Evolution that speaks directly to the xxx Global SMTP servers.

Using postfix as your local MTA is highly recommended. The configuration is easy and works with systems that use either DHCP or static IP addresses. The following instructions configure postfix to use the us.xxx.com relay host for all outgoing mail.

    1。 In a new file named /etc/postfix/sender_canonical add the following line. The localuserid shown should be the user id you login to Linux with. Replace the email address with your email address. For example, this might be [email protected].

    localuserid    [email protected]

    Tip: Postfix uses the sender_canonical database to set the correct Return-Path header on outgoing email. Setting a valid Return-Path address helps ensure your emails do not get flagged as spam.
    2。Create the postfix sender_canonical.db using the following command. This should be run every time you change the /etc/postfix/sender_conical file.

    /usr/sbin/postmap /etc/postfix/sender_canonical

    3。 Create a postfix transport map to skip the xxx internal relays when sending email from your local system to other LTC email addresses. If you don't do this, then email will pass throught the corporate xxx antivirus and spam relays multiple times. Multiple passes through the xxx corporate antivirus and spam servers could delay email you send.

    echo "linux.xxx.com   smtp:linux.xxx.com" >> /etc/postfix/transport
    /usr/sbin/postmap /etc/postfix/transport

    4。Use /usr/sbin/postconf to add the following three lines to the /etc/postfix/main.cf config file. The first two commands tell postfix to use the new sender_canonical and transport databases you created. The third command tells postfix to send all outgoing mail through the us.xxx.com relay. (In the special case of configuring an MTA, do not use a relay.xxx.com server!)

    /usr/sbin/postconf -e sender_canonical_maps=hash:/etc/postfix/sender_canonical
    /usr/sbin/postconf -e transport_maps=hash:/etc/postfix/transport
    /usr/sbin/postconf -e relayhost=us.xxx.com

    5。Assuming postfix is currently running, restart it using the command /usr/sbin/postfix reload. Check the /var/log/maillog file on Red Hat or /var/log/mail on SUSE for any errors.

Testing your configuration

Test your postfix configuration by sending an email from the command line of your workstation. You must be logged in using your normal unprivilaged user id for this test! Be sure to replace [email protected] in the command below with your correct LTC IMAP email address.

echo 'test mail' | mail -s 'Test Mail' [email protected]

收gmail的配置

http://souptonuts.sourceforge.net/postfix_tutorial.html

not work



你可能感兴趣的:(linux,command,user,System,email,encryption)