今天突然接到需求要定期撈出所有ERP系統的相關資訊給頭頭,shell都寫完了才發現mail發不出去,想到目前ERP還跑在Redhat5上,

以往透過mailx套件,並修改/etc/mail.rc後應該要可以正常發mail,後來花點時間google,才知道Redhat 5預設的mailx版本跟sendmail是綁在一起的

所以mail這個指令實際是透過sendmail這個服務去發,要解決這個問題有兩種方式:

1.手動安裝新版mailx。

2.修改sendmail config讓其可以透過其他SMTP來relay。

而我選擇第二種方式,以下為sendmail config,設定完就可以直接用mail指令來發送信件,

Configuring Sendmail in Queue-Only Mode

# vim /etc/sysconfig/sendmail

Modify the “DAEMON” line. Set DAEMON=no. This will make sendmail to be executed in a queue-only mode on the machine. The SMTP Server will sent but not receive mail requests.

DAEMON=no

Configure Mail Submission

Configure local server to use central MTA  to be the sender of your mail for your domain

vim /etc/mail/submit.cf

D{MTAHost}mailproxy.myLAN.com

# service sendmail restart

但接下來遇到另一個問題,Redhat 預設的sendmail套件,沒有附件功能阿,不過還是有解,透過 uuencode 指令可以達成此目的,

請參閱下方範例,可以同時附加多個附件。

for attachment in $attachments ; do

uuencode $attachment $attachment

done | mail -s "TPAP Linux User List&Access Right-$today" xxx@.com xxx@.com -c "xxx@.com"

 

arrow
arrow
    文章標籤
    Redr redhat5 sendmail
    全站熱搜
    創作者介紹
    創作者 MXLI 的頭像
    MXLI

    mxli的部落格

    MXLI 發表在 痞客邦 留言(0) 人氣()