Sending mail from a Bash shell script

前端 未结 12 1497
梦毁少年i
梦毁少年i 2021-01-29 22:54

I am writing a Bash shell script for Mac that sends an email notification by opening an automator application that sends email out with the default mail account in Mail.app. The

12条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-29 23:40

    There is a program called Sendmail.

    You probably don't want to use the -bs command unless you are sending it as raw SMTP like Martin's example. -bs is for running an SMTP server as a deamon. Sendmail will send directly to the receiving mail server (on port 25) unless you override it in the configuration file. You can specify the configuration file by the -C paramter.

    In the configuration, you can specify a relay server (any mail server or sendmail running -bs on another machine)

    Using a properly configured relay server is good idea because when IT manages mail servers they implement SPF and domain keys. That keeps your mail out of the junk bin.

    If port 25 is blocked you are left with two options.

    1. Use the corporate SMTP server.
    2. Run sendmail -bd on a machine outside of the corporate firewall that listens on a port other than 25.

    I believe you can add configuration parameters on the command line. What you want is the SMART_HOST option. So call Sendmail like sendmail -OSMART_HOST=nameofhost.com.

提交回复
热议问题