发送主题为变量的邮件
Sending mail with subject as variable
这里我想使用 unix shell 脚本发送邮件。
我使用以下脚本进行简单的邮寄:
echo 'Message body goes here' | mail -s 'subject line goes here' email@provider.com
注意:现在我想发送主题来自其他文件的邮件,使用如下所示的变量。
文件 1:
该文件包含以下脚本:
#!/bin/bash
subjectvariable="Subject is here"
export $subjectvariable
我想得到这个 $subjectvariable
应该在邮件命令中作为变量使用。
我的尝试:
文件 2:
#!/bin/bash
echo 'Message body goes here' | mail -s "$subjectvariable" email@provider.com
但是在输出中我没有得到主题。
仅用于 echo 命令的变量工作文件,如下图所示:
这应该有效
文件 1:
#!/bin/bash
subjectvariable="Subject is here"
export subjectvariable=$subjectvariable
和 exec file2 之前的源文件 1
这里我想使用 unix shell 脚本发送邮件。
我使用以下脚本进行简单的邮寄:
echo 'Message body goes here' | mail -s 'subject line goes here' email@provider.com
注意:现在我想发送主题来自其他文件的邮件,使用如下所示的变量。
文件 1:
该文件包含以下脚本:
#!/bin/bash
subjectvariable="Subject is here"
export $subjectvariable
我想得到这个 $subjectvariable
应该在邮件命令中作为变量使用。
我的尝试:
文件 2:
#!/bin/bash
echo 'Message body goes here' | mail -s "$subjectvariable" email@provider.com
但是在输出中我没有得到主题。
仅用于 echo 命令的变量工作文件,如下图所示:
这应该有效
文件 1:
#!/bin/bash
subjectvariable="Subject is here"
export subjectvariable=$subjectvariable
和 exec file2 之前的源文件 1