V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
a22124497
V2EX  ›  问与答

求助一下 Linux 下代理上网 并 smtp 发邮件的问题

  •  
  •   a22124497 · 2020-02-19 14:46:09 +08:00 · 1868 次点击
    这是一个创建于 1518 天前的主题,其中的信息可能已经有所发展或是发生改变。

    q 求助一下 linux 下代理上网 并 smtp 发邮件的问题

    云主机,有公网开了个 squid,搞了 http 代理。另一台没公网的,直接

    /etc/profile 中 http_proxy=http://192.168.1.115:3128 这样的

    curl 可以上网了,直接 curl smtp.xxx.com 也可以通,配置 /etc/mail.rc ,在可以上网的机器上,直接 mail 发送邮件上就 ok 了,在不能上网的机器上,就不 ok。

    网上查了一下,说是 squid 不支持 smtp 代理,好想加要改成透明,或是 nat 什么的,那样好像就略复杂了

    有没啥简单的方法,可以代理 smtp 呀

    1 条回复    2020-02-19 15:50:53 +08:00
    ps1aniuge
        1
    ps1aniuge  
       2020-02-19 15:50:53 +08:00
    $附件 = Get-ChildItem '/tmp/aaaa.tar.gz'
    $HTML 邮件内容 =
    @'
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    </head>
    <body>
    <p>
    <span style="font-family:Microsoft YaHei;font-size:18px;">html 信件内容</span>
    </p>
    </body>
    </html>
    '@

    Send-MailMessage -Subject "主题" `
    -From "你的 hotmail 账户 @hotmail.com" -To "你的 qq 邮箱 @qq.com" `
    -SmtpServer "smtp.live.com" -Port 587 -UseSsl -Credential "你的 hotmail 账户 @hotmail.com" `
    -Attachments $附件 -BodyAsHTML -body $HTML 邮件内容


    上面的代码,保存成带有 bom 头的 a.ps1 文件,utf8 编码。
    win 中用:
    powershell.exe -file d:\你的目录\a.ps1

    linux 中用:
    /usr/bin/pwsh -file /你的目录 /a.ps1

    ------------------------------------------------------
    centos7,centos8,安装 powershell:
    curl -o /etc/yum.repos.d/microsoft.repo https://packages.microsoft.com/config/rhel/7/prod.repo
    sudo yum remove -y powershell #删除旧版
    sudo yum install -y powershell
    pwsh -c 'mkdir -p "$env:HOME/.config/powershell" '
    pwsh -c 'Add-Content -Value "Set-PSReadlineOption -EditMode Windows" -LiteralPath $profile '
    pwsh -c 'Add-Content -Value "`nSubsystem powershell /usr/bin/pwsh -sshs -NoLogo -NoProfile" -LiteralPath /etc/ssh/sshd_config '



    ubuntu1604:
    sudo curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
    sudo curl -o /etc/apt/sources.list.d/microsoft.list https://packages.microsoft.com/config/ubuntu/16.04/prod.list
    sudo apt-get update
    sudo apt-get remove -y powershell #删除旧版
    sudo apt-get install -y powershell
    pwsh -c 'mkdir -p "$env:HOME/.config/powershell" '
    pwsh -c 'Add-Content -Value "Set-PSReadlineOption -EditMode Windows" -LiteralPath $profile '
    pwsh -c 'Add-Content -Value "`nSubsystem powershell /usr/bin/pwsh -sshs -NoLogo -NoProfile" -LiteralPath /etc/ssh/sshd_config '


    ubuntu1804:
    sudo curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
    sudo curl -o /etc/apt/sources.list.d/microsoft.list https://packages.microsoft.com/config/ubuntu/18.04/prod.list
    sudo apt-get update
    sudo apt-get remove -y powershell #删除旧版
    sudo apt-get install -y powershell
    pwsh -c 'mkdir -p "$env:HOME/.config/powershell" '
    pwsh -c 'Add-Content -Value "Set-PSReadlineOption -EditMode Windows" -LiteralPath $profile '
    pwsh -c 'Add-Content -Value "`nSubsystem powershell /usr/bin/pwsh -sshs -NoLogo -NoProfile" -LiteralPath /etc/ssh/sshd_config '



    debian9:Deepin 深度操作系统,当前版本,基于 debian9。
    sudo apt-get update
    sudo apt-get install curl gnupg apt-transport-https
    curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
    sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch main" > /etc/apt/sources.list.d/microsoft.list'
    sudo apt-get update
    sudo apt-get remove -y powershell #删除旧版
    sudo apt-get install -y powershell
    pwsh -c 'mkdir -p "$env:HOME/.config/powershell" '
    pwsh -c 'Add-Content -Value "Set-PSReadlineOption -EditMode Windows" -LiteralPath $profile '
    pwsh -c 'Add-Content -Value "`nSubsystem powershell /usr/bin/pwsh -sshs -NoLogo -NoProfile" -LiteralPath /etc/ssh/sshd_config '
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1011 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 20:07 · PVG 04:07 · LAX 13:07 · JFK 16:07
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.