Skip to content

Commit ab920b2

Browse files
authored
Updated SMPT server (quic#830)
Updated the SMPT server Signed-off-by: Rishin Raj <rishinr@qti.qualcomm.com>
1 parent 94f233e commit ab920b2

1 file changed

Lines changed: 43 additions & 14 deletions

File tree

.github/workflows/daily-pr-report.yml

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,49 @@ jobs:
107107
print(f"report.html written ({{len(html):,}} bytes)")
108108
EOF
109109
110-
- name: Send email
110+
- name: Send email via SMTP using Python
111111
# continue-on-error so a transient SMTP failure doesn't mark the whole
112112
# workflow run as failed — the report was still generated and logged.
113113
continue-on-error: true
114-
uses: dawidd6/action-send-mail@v3
115-
with:
116-
server_address: ${{ secrets.SMTP_SERVER }}
117-
server_port: ${{ secrets.SMTP_PORT }}
118-
# Leave username/password empty for open relays (e.g. smtphost.qualcomm.com:25)
119-
username: ${{ secrets.SMTP_USERNAME }}
120-
password: ${{ secrets.SMTP_PASSWORD }}
121-
# Disable TLS for plain-SMTP port-25 open relays
122-
secure: false
123-
subject: "Open PR Dashboard — ${{ github.repository }} — ${{ github.run_number }}"
124-
to: ${{ env.MAIL_RECIPIENTS }}
125-
from: ${{ secrets.MAIL_FROM }}
126-
html_body: file://report.html
114+
env:
115+
SMTP_SERVER: ${{ secrets.SMTP_SERVER }}
116+
SMTP_PORT: ${{ secrets.SMTP_PORT }}
117+
SMTP_USERNAME: ${{ secrets.SMTP_USERNAME }}
118+
SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }}
119+
MAIL_TO: ${{ env.MAIL_RECIPIENTS }}
120+
MAIL_FROM: ${{ secrets.MAIL_FROM }}
121+
run: |
122+
python - << 'EOF'
123+
import os
124+
import smtplib
125+
from email.mime.text import MIMEText
126+
from email.header import Header
127+
from pathlib import Path
128+
129+
smtp_server = os.environ.get("SMTP_SERVER")
130+
smtp_port = int(os.environ.get("SMTP_PORT", "25"))
131+
smtp_user = os.environ.get("SMTP_USERNAME") or None
132+
smtp_pass = os.environ.get("SMTP_PASSWORD") or None
133+
mail_to = os.environ["MAIL_TO"]
134+
mail_from = os.environ["MAIL_FROM"]
135+
136+
# Read HTML body
137+
html = Path("report.html").read_text(encoding="utf-8")
138+
msg = MIMEText(html, "html", "utf-8")
139+
subject = f"Open PR Dashboard — {os.environ.get('GITHUB_REPOSITORY', '')} — {os.environ.get('GITHUB_RUN_NUMBER', '')}"
140+
msg["Subject"] = Header(subject, "utf-8")
141+
msg["From"] = mail_from
142+
msg["To"] = mail_to
143+
144+
recipients = [addr.strip() for addr in mail_to.split(",") if addr.strip()]
145+
if not smtp_server:
146+
raise SystemExit("SMTP_SERVER is not set")
147+
148+
with smtplib.SMTP(smtp_server, smtp_port, timeout=60) as server:
149+
# If credentials are provided, use them; otherwise assume open relay
150+
if smtp_user and smtp_pass:
151+
server.login(smtp_user, smtp_pass)
152+
server.sendmail(mail_from, recipients, msg.as_string())
153+
154+
print("Mail sent to:", ", ".join(recipients))
155+
EOF

0 commit comments

Comments
 (0)