DKIM signatures on Hmailserver not added with scripted message

Use this forum if you have problems with a hMailServer script, such as hMailServer WebAdmin or code in an event handler.
Post Reply
alexvremja
New user
New user
Posts: 5
Joined: 2016-04-27 06:14

DKIM signatures on Hmailserver not added with scripted message

Post by alexvremja » 2016-04-29 02:10

Hi Everybody!

Great work, jimimaseye viewtopic.php?f=21&t=29402
Thanks a lot!

I installed and it works well.... if I send a mail from thunderbird

but if I generate a mail via api from the server (w/ classic asp)..
like this https://www.hmailserver.com/documentati ... ssage_send

mail has no DKIM signature and google mx reject it

clearly I'm forgetting something but I've not found what :-(

I've found this routine, but seems me the way to programmatically setup the account, but I've already successfully configured manually

Code: Select all

Set oApp = CreateObject("hMailServer.Application")
Call oApp.Authenticate("Administrator","hMailPass") '*** N.B. 1. set your administrator password in this line

sDomain = "mydomain.com" ' *** enter domain name for DKIM here

Set oDomain = oApp.Domains.ItemByName(sDomain) 

oDomain.DKIMPrivateKeyFile = "c:\path to key file"
oDomain.DKIMSelector = "selector"
etc
etc

oDomain.Save()
can you suggest the path for the solution

Thanks a lot!

Alex

User avatar
mattg
Moderator
Moderator
Posts: 21184
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: HOW TO: Easy Set Up DKIM signatures on Hmailserver

Post by mattg » 2016-04-29 03:04

don't authenticate with the hmailserver administrator

authenticate with an actual account and password on hmailserver
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

User avatar
jimimaseye
Moderator
Moderator
Posts: 8849
Joined: 2011-09-08 17:48

Re: HOW TO: Easy Set Up DKIM signatures on Hmailserver

Post by jimimaseye » 2016-04-29 10:03

alexvremja wrote:
but if I generate a mail via api from the server (w/ classic asp)..
like this https://www.hmailserver.com/documentati ... ssage_send
I have just done a careful test and the DKIM signing is added correctly even by a script generated email.

Code: Select all

  Set newMessage = CreateObject("hMailServer.Message")
      newMessage.HeaderValue("Message-ID") = "<" & CreateGUIDval & ">"
      newMessage.From = SendFrom
      newMessage.FromAddress = SendFromAddress
      newMessage.Subject = SendSubject
      newMessage.AddRecipient "", SendAddRecipient
      newMessage.Body = SendBody
      newMessage.Save

NOTE: it is important that the destination address is not a local domain - sending local to local doesnt apply the DKIM signing. However, if the destination address is external then the DKIM signature was added correctly. Also, ensure that the FROM header contains a valid email address from your domain (eg, "name <user@yourdomain.com>" (Remember the FROM field is not the same as the FROMADDRESS field.

What version of HMS are you using? And can you post your script (the part creating the email) here.
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

alexvremja
New user
New user
Posts: 5
Joined: 2016-04-27 06:14

Re: HOW TO: Easy Set Up DKIM signatures on Hmailserver

Post by alexvremja » 2016-04-29 14:33

Hi jimimaseye,
thank you for answering and for prompt answer

actually I'm using a function to send the mail:

Code: Select all

	Function SendjsMail(From,FromAddress,UUID,Subject,RecipientName,RecipientAddress,HBody,TBody)
		dim oMessage
		Set oMessage = server.CreateObject("hMailServer.Message")
		oMessage.From = From&"<"&FromAddress&">"
		oMessage.HeaderValue("UUID") = UUID
		oMessage.Subject = Subject
		oMessage.AddRecipient RecipientName,RecipientAddress
		oMessage.HeaderValue("To")= RecipientName
		oMessage.HTMLBody = HBody
		oMessage.Body=TBody
		oMessage.Save 
	End Function
yes, From Field contains a valid email and clearly the recipient address is an external address (not gmail.com since it reject immediately, but other country provider)

What I see comparing your routine and my, is that I'm not populating FromAddress (I thought From with address was enough) and I'm not adding Messagge-ID value (I'm adding a UUID for other purposes)

I've modified my routine adding these 2 fields and problem has been solved.

Therefore next question is: where can find all these info: I read you suggest to check PHPWebAdmin but that's PHP.. is there nothing in old classic asp?

Thanks a lot again for your time

Alex

User avatar
jimimaseye
Moderator
Moderator
Posts: 8849
Joined: 2011-09-08 17:48

Re: HOW TO: Easy Set Up DKIM signatures on Hmailserver

Post by jimimaseye » 2016-04-29 14:37

Well done. FromAddress is mandatory.

ComAPI documentation: https://www.hmailserver.com/documentati ... om_objects

By the way RFC suggest you SHOULD have field "Message-ID" in emails. Although not obligatory, it helps in particular in spam fighting (absence or duplicate message-id's are seen as suspicious and possibly the email could then be put in a spam box or even rejected). I recommend you add it. (Its presence also help with REPLIES to show threading).
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

alexvremja
New user
New user
Posts: 5
Joined: 2016-04-27 06:14

Re: HOW TO: Easy Set Up DKIM signatures on Hmailserver

Post by alexvremja » 2016-04-29 14:38

mattg wrote:don't authenticate with the hmailserver administrator

authenticate with an actual account and password on hmailserver
Hi Mattg!

Not sure your comment was referred to me, but, yes never use Admin to login..

but I just copied a routine I found in some post

anyway thanks for remember security issues

Alex

alexvremja
New user
New user
Posts: 5
Joined: 2016-04-27 06:14

Re: HOW TO: Easy Set Up DKIM signatures on Hmailserver

Post by alexvremja » 2016-04-29 14:55

jimimaseye wrote:Well done. FromAddress is mandatory.

ComAPI documentation: https://www.hmailserver.com/documentati ... om_objects

By the way RFC suggest you SHOULD have field "Message-ID" in emails. Although not obligatory, it helps in particular in spam fighting (absence or duplicate message-id's are seen as suspicious and possibly the email could then be put in a spam box or even rejected). I recommend you add it. (Its presence also help with REPLIES to show threading).
Yes, I added also Message-ID while testing and I was planning to leave it,

Surely I'm OT, but still a small issue: when I receive the mail I see in "To" field the Name, but email address is empty:

now I have

Code: Select all


      oMessage.AddRecipient RecipientName,RecipientAddress
      oMessage.HeaderValue("To")= RecipientName
if I modify to

Code: Select all

      oMessage.AddRecipient RecipientName,RecipientAddress
      oMessage.HeaderValue("To")= RecipientName&" <"&RecipientAddress&">"
it will show only the email address:

How to have both?

Alex

User avatar
jimimaseye
Moderator
Moderator
Posts: 8849
Joined: 2011-09-08 17:48

Re: HOW TO: Easy Set Up DKIM signatures on Hmailserver

Post by jimimaseye » 2016-04-29 16:32

Im not sure why you are adding the TO header separately.

Normally the .ADDRECIPIENT function is sufficient (I see the TO field populated accordingly). My script (above) shows the recipient in the TO field without a problem. Try leaving that bit out.
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

alexvremja
New user
New user
Posts: 5
Joined: 2016-04-27 06:14

Re: HOW TO: Easy Set Up DKIM signatures on Hmailserver

Post by alexvremja » 2016-04-29 17:26

jimimaseye wrote:Im not sure why you are adding the TO header separately.

Normally the .ADDRECIPIENT function is sufficient (I see the TO field populated accordingly). My script (above) shows the recipient in the TO field without a problem. Try leaving that bit out.
Actually I do not know exactly.. I read so many posts these days and for each I took something and put all together that I do not remember exactly the reason for each

I think add separate TO header was related to BCC feature

anyway will test immediately.

Thanks again!

Alex

User avatar
jimimaseye
Moderator
Moderator
Posts: 8849
Joined: 2011-09-08 17:48

Re: DKIM signatures on Hmailserver not added with scripted message

Post by jimimaseye » 2016-04-29 18:21

(topic moved to SCRIPTING) - "DKIM signatures on Hmailserver not added with scripted message"
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

Post Reply