Hello,
I would like to have some help with the next issue:
I set up hmail server to work with several aplications using amazon AWS as relay, and it was working ok, last week one of my colegues released a new application to send notifications, but it did not work (the rest of apps are still working fine).
After checking the logs I found that messages sent from the new application were being bounced by amazon as the "from" field was empty:
"SENT: MAIL FROM:<>"
"RECEIVED: 501 Invalid MAIL FROM address provided"
I understand that it is normal, and I know that eventhough I enabled blank fields in hmail server it is amazon who is rejecting those messages, however I can not change either amazon or the application settings to change this scenario, so I would need to change the empty "from" field using hmailserver scripts.
I have used scripts to change subject in the past, but I have not been able to do so with empty senders I think there is something wrong with my syntaxis:
Sub OnAcceptMessage(oClient, oMessage)
If oMessage.From = "" Then
oMessage.From = "<noreply@mydomain.com>"
End If
oMessage.save
End Sub
Please help!!!
Script to change "from" field when it is empty / blank
-
miguel.cardenas
- New user

- Posts: 3
- Joined: 2014-01-03 16:42
Re: Script to change "from" field when it is empty / blank
You want oMessage.FromAddress instead of oMessage.From because from is the "name" vs address.
Bill
Bill
hMailServer build LIVE on my servers: 5.4-B2014050402
#hmailserver on FreeNode IRC https://webchat.freenode.net/?channels=#hmailserver
*** ABSENT FROM hMail! Those in IRC know how to find me if urgent. ***
#hmailserver on FreeNode IRC https://webchat.freenode.net/?channels=#hmailserver
*** ABSENT FROM hMail! Those in IRC know how to find me if urgent. ***
-
miguel.cardenas
- New user

- Posts: 3
- Joined: 2014-01-03 16:42
Re: Script to change "from" field when it is empty / blank
Hi,
Thanks for your quick response, I changed the code for
_______________
Sub OnAcceptMessage(oClient, oMessage)
If oMessage.FromAddress = "" Then
oMessage.FromAddress = "no reply@mydomain.com"
oMessage.From = "No reply"
End If
oMessage.save
End Sub
____________________
It did change the email address in the "mail from" section, but I think the application is adding a "from" in the header which is also empty.
I am getting the next error message: Empty required header 'From'
Is there a way to define the "from" field in the header using script? something like oHeader.from or similar?
Thanks in advance
Thanks for your quick response, I changed the code for
_______________
Sub OnAcceptMessage(oClient, oMessage)
If oMessage.FromAddress = "" Then
oMessage.FromAddress = "no reply@mydomain.com"
oMessage.From = "No reply"
End If
oMessage.save
End Sub
____________________
It did change the email address in the "mail from" section, but I think the application is adding a "from" in the header which is also empty.
I am getting the next error message: Empty required header 'From'
Is there a way to define the "from" field in the header using script? something like oHeader.from or similar?
Thanks in advance
Re: Script to change "from" field when it is empty / blank
oMessage.From is the from name oMessage.FromAddress is the email address. We'd have to see your headers to know what it doesn't like. Maybe one of the rec'd headers. You might need to adjust a setting or add/remove/change some other header but hard to say without seeing the headers.
You can redact IP/addresses if needed
Bill
Bill
hMailServer build LIVE on my servers: 5.4-B2014050402
#hmailserver on FreeNode IRC https://webchat.freenode.net/?channels=#hmailserver
*** ABSENT FROM hMail! Those in IRC know how to find me if urgent. ***
#hmailserver on FreeNode IRC https://webchat.freenode.net/?channels=#hmailserver
*** ABSENT FROM hMail! Those in IRC know how to find me if urgent. ***
-
miguel.cardenas
- New user

- Posts: 3
- Joined: 2014-01-03 16:42
Re: Script to change "from" field when it is empty / blank
Thank you for your answer, it was really helpfull
Using the oMessage.FromAddress field in the script I can enforce the sender ("from") in the header, and I do not have an error message any more.
Thanks again.
Here is the final code in case somebody could need it.
_________________________
Sub OnAcceptMessage(oClient, oMessage)
If oMessage.FromAddress = "" Then
oMessage.FromAddress = "noreply@mydomain.com"
oMessage.From = "noreply@mydomain.com"
oMessage.FromAddress = "noreply@mydomain.com"
End If
oMessage.save
End Sub
__________________________
Using the oMessage.FromAddress field in the script I can enforce the sender ("from") in the header, and I do not have an error message any more.
Thanks again.
Here is the final code in case somebody could need it.
_________________________
Sub OnAcceptMessage(oClient, oMessage)
If oMessage.FromAddress = "" Then
oMessage.FromAddress = "noreply@mydomain.com"
oMessage.From = "noreply@mydomain.com"
oMessage.FromAddress = "noreply@mydomain.com"
End If
oMessage.save
End Sub
__________________________
Re: Script to change "from" field when it is empty / blank
Glad you got it sorted. Why do you have fromaddress twice? does that help fix the problem or typo?
Bill
Bill
hMailServer build LIVE on my servers: 5.4-B2014050402
#hmailserver on FreeNode IRC https://webchat.freenode.net/?channels=#hmailserver
*** ABSENT FROM hMail! Those in IRC know how to find me if urgent. ***
#hmailserver on FreeNode IRC https://webchat.freenode.net/?channels=#hmailserver
*** ABSENT FROM hMail! Those in IRC know how to find me if urgent. ***
Re: Script to change "from" field when it is empty / blank
I think the issue part way through this thread is the space in the email address.
email addresses can't contain a space
email addresses can't contain a space
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation
https://www.hmailserver.com/documentation

