Skip to content

Commit

Permalink
Allow SMTP HELO Hostname to be manually specified. (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjkw31 authored Oct 28, 2024
1 parent d5f134e commit 83ea964
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,10 @@ builder:
port: int # Port of the GSB server
recipes:
toAddr: Optional[str] # Address to which recipe requests will be sent.
fromAddr: Optional[str] # Address from which recipe requests will be sent.
smtp: Optional[str] # Address to an SMTP relay
toAddr: Optional[str] # Address to which recipe requests will be sent.
fromAddr: Optional[str] # Address from which recipe requests will be sent.
smtp: Optional[str] # Address to an SMTP relay
localHostname: Optional[str] # Hostname to use for SMTP HELO.
```

## Usage
Expand Down
1 change: 1 addition & 0 deletions softpack_core/config/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,4 @@ class RecipeConfig(BaseModel):
toAddr: Optional[str]
fromAddr: Optional[str]
smtp: Optional[str]
localHostname: Optional[str]
8 changes: 7 additions & 1 deletion softpack_core/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,13 @@ async def request_recipe( # type: ignore[no-untyped-def]
msg["From"] = recipeConfig["fromAddr"]
msg["To"] = recipeConfig["toAddr"]

s = smtplib.SMTP(recipeConfig["smtp"])
localhostname = None

if recipeConfig["localHostname"] is not None:
localhostname = recipeConfig["localHostname"]


s = smtplib.SMTP(recipeConfig["smtp"], local_hostname=localhostname)
s.sendmail(
recipeConfig["fromAddr"],
[recipeConfig["toAddr"]],
Expand Down

0 comments on commit 83ea964

Please sign in to comment.