首页 > 解决方案 > How to stop mails from going to /var/spool/mail/$USER folder and redirect them to the personal mail

问题描述

I've written a script which sends an HTML file through the mail using mailx.

My code is:

mail_id=demo@host.com cat /home/oretail/tmp/main.html | mailx -s "$(echo 'Subject Content-Type: text/html')" $mail_id

The mail is going to /var/spool/mail/root folder.it's not coming to the specified e-mail id.

How to do i this?

mail_id=demo@host.com cat /home/oretail/tmp/main.html | mailx -s "$(echo 'Subject Content-Type: text/html')" $mail_id

标签: htmlshell

解决方案


mailx does not deliver e-mail to the recipient, it is user agent. It puts a message to the queue to local MTA (Mail Transfer Agent) which can be sendmail, postfix, nullmailer,... or to remote SMTP server using following option

-S smtp=smtp://your_smtp_server.com

Messages in /var/spool/mail/root are most probably notifications about non delivered messages.


推荐阅读