【问题标题】:Sending email with Github Actions使用 Github Actions 发送电子邮件
【发布时间】:2021-11-12 17:49:38
【问题描述】:

我正在探索 Github Actions,我想发送带有 Github 操作的电子邮件。 但是github给了我以下错误。

Run dawidd6/action-send-mail@v3.6.0
Error: Invalid login: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbt
534-5.7.14 q937LSp00ryw6TWRxw0-nnKJEijBq83UwreLR6Bu4wr_MwGSeBWNF6rFleIEyw6a9Z0Le
534-5.7.14 b7A1GlsFzIiog5p_U3BAcRhFo5EWeHW25UREP_QJ2oZPf5ZKHynU-D6iScC6bopH>
534-5.7.14 Please log in via your web browser and then try again.
534-5.7.14  Learn more at
534 5.7.14  https://support.google.com/mail/answer/78754 fw21sm11223135pjb.25 - gsmtp

error Image

我关注this article发送 带有 Github 操作的电子邮件。

我的.yml 代码如下所示。

name: GitHub Actions Demo
on: [push]
jobs:
  Explore-GitHub-Actions:
    runs-on: ubuntu-latest
    steps:
      - run: echo "???? The job was automatically triggered by a ${{ github.event_name }} event."
      - run: echo "???? This job is now running on a ${{ runner.os }} server hosted by GitHub!"
      - run: echo "???? The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
      - name: Check out repository code
        uses: actions/checkout@v2
      - run: echo "???? The ${{ github.repository }} repository has been cloned to the runner."
      - run: echo "????️ The workflow is now ready to test your code on the runner."
      - name: List files in the repository
        run: |
          ls ${{ github.workspace }}
      - run: echo "???? This job's status is ${{ job.status }}."

  sending-email:
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository code
        uses: actions/checkout@v2
      - name: Send email
        uses: dawidd6/action-send-mail@v3.6.0
        with:
          server_address: smtp.gmail.com
          server_port: 465
          username: ${{secrets.GMAIL_USERNAME}}
          password: ${{secrets.GMAIL_PASSWORD}}
          subject: Message from github actions.
          to: dulench.deori564@gmail.com
          from: deepak deori
          secure: true
          body: workflow for ${{github.repository}} completed successfully!

在我的第二份工作中,我指定发送电子邮件。

【问题讨论】:

    标签: github yaml smtp


    【解决方案1】:

    Gmail 安全设置可能会导致此操作失败。此故障会向您发送此消息。

    可能需要更改 Gmail 设置才能使此操作生效。

    1. 检查 IMAP 是否开启:https://support.google.com/mail/answer/7126229?hl=en#zippy=%2Cstep-check-that-imap-is-turned-on

    2. 转到您的帐户并启用双重身份验证:https://myaccount.google.com/security

    3. 设置 2FA 后,您需要创建应用密码。此博客解释了如何创建它:https://umd.service-now.com/itsupport?id=kb_article&article=KB0015112&sys_kb_id=76433076dbdf8c904cb035623996194b&spa=1

    那么您需要为这个新的应用密码更新${{secrets.GMAIL_PASSWORD}}

    【讨论】:

      【解决方案2】:

      查看此存储库后,我已在其中设置了邮件服务 https://github.com/GitHub-Campus-IITM/support/blob/main/.github/workflows/hiring.yml

      on:
        issues:
          types: [labeled]
      
      jobs:
        Broadcast:
          if: ${{ github.event.label.name == 'Hiring' }}
          runs-on: ubuntu-latest
          steps:
            - name: Issue Parser
              uses: stefanbuck/github-issue-parser@v2
              id: issue-parser
              with:
                template-path: .github/ISSUE_TEMPLATE/Opportunity.yml
            - run: | 
                JSON=`echo '${{ steps.issue-parser.outputs.jsonString }}'`
                echo $JSON
                com=`echo $(jq -r '.company' <<< "$JSON")`
                reg=`echo $(jq -r '.registration' <<< "$JSON")`
                jd=`echo $(jq -r '.jd' <<< "$JSON")`
                echo "<h1> Opprtunity from `echo $com` </h1> <div> <h2>Job Description</h2><div>`echo $jd` </div></div><div>Interested students please apply here: `echo $reg`<div>" > temp.html
                    
            - name: Send mail
              uses: dawidd6/action-send-mail@v3
              with:
                server_address: smtp.gmail.com
                server_port: 465
                username: ${{SECRETS.EMAIL}}
                password: ${{SECRETS.PASSWORD}}
                subject: Opportunity for you
                to: github-campus-group@smail.iitm.ac.in
                cc: ce20b112@smail.iitm.ac.in
                from: GitHub Campus Expert
                html_body: file://temp.html
                secure: true
                ignore_cert: true
                convert_markdown: true
                priority: low
                
            - name: Close Issue
              uses: peter-evans/close-issue@v1
              with:
                comment: |
                  Thank you very much for this opportunity.
                  We have forwarded it to the students ⭐⭐.
      

      还有一些额外的东西,但我认为这会对你有所帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-09-08
        • 2021-09-27
        • 1970-01-01
        • 2016-04-17
        • 2017-12-07
        • 1970-01-01
        • 1970-01-01
        • 2022-07-27
        相关资源
        最近更新 更多