Put a copy of outgoing emails to Sent folder.

Use this forum if you have problems with a hMailServer script, such as hMailServer WebAdmin or code in an event handler.
Post Reply
kdiamond
Normal user
Normal user
Posts: 94
Joined: 2013-03-20 10:51

Put a copy of outgoing emails to Sent folder.

Post by kdiamond » 2016-05-16 12:31

Hello.

This feature has been discussed before. It should work similar to exchange etc. When email is sent out, the server should automatically put it to Send folder. Now the email clients needs to send each email twice. First for sending the email, then again to place a copy it in Sent folder. Quite a nonsense to me. Specially if there is an attachment included.

I wish I knew how to create a scripts. But since I don't I'm asking is there is someone who would make it for me against the payment of course.

Thank you.
Br,
Kd

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

Re: Put a copy of outgoing emails to Sent folder.

Post by jimimaseye » 2016-05-16 12:58

I cant help yoiu with your script. But I would like to comment on your statement (by means of discussion):
kdiamond wrote:First for sending the email, then again to place a copy it in Sent folder. Quite a nonsense to me.
Your suggestion implies all outgoing email should go in to SENT folder. What happens if the email client is using POP only (to collect his email)?

a, This would just create a folder that would never be seen by the user (POP3 user dont see folders on the server except the INBOX) and
b, Folders and their contents take space. What would the point be of holding thousands of emails in a SENT folder on a server that is NEVER going to be seen or ever cleared down. (This could lead to expensive diskspace/quotas been used and its subsequent problems).

Also, I know that Gmail (and maybe Hotmail - or at least they used to) automatically apply copies to the sent folder without the need of the client putting it there, but

a, acknowledging my point above, they give a lot of disk space so it doesnt matter if you fill it with emails you never see
b, their model of using their email service is to assume you are using there facilities anyway (GMAIL) which is heavily online or at least IMAP centric (so their sent folder will always be viewed whether you want to or not)
c, they are the only two providers I know to do this. (Yahoo definitely doesnt and not sure about Office365.com although the screenshot below also suggests they dont). Other hosts require the email client to put/copy the sent email in to the sent folder as required.

Setting example (taken from Office 365 - Configure Mozilla Thunderbird for Office 365 ):
Image.

Also, automatically moving sent email to the imap SENT folder when using SMTP is not RFC instruction. SMTP and IMAP protocols are completely separate. (And Hmailserver is based on RFC's).

The script: I cannot see how it can be done. The outgoing message doesnt belong to any folder and therefore is not registered in the database and therefore cannot be manipulated. But Im no expert.
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

User avatar
SorenR
Senior user
Senior user
Posts: 4167
Joined: 2006-08-21 15:38
Location: Denmark

Re: Put a copy of outgoing emails to Sent folder.

Post by SorenR » 2016-05-16 14:05

jimimaseye wrote:The script: I cannot see how it can be done. The outgoing message doesnt belong to any folder and therefore is not registered in the database and therefore cannot be manipulated. But Im no expert.
Only popping in for a comment (brainstorming)

oClient.Username hold the sender i.e. user and domain.
oMessage.Copy("Sent Items") will copy a message to an IMAP folder.

Now, the challenge; can we access the message under OnAcceptMessage(oClient, oMessage) and do the server hold rights to copy to the destination folder?

Code: Select all

Sub OnAcceptMessage(oClient, oMessage)
   If InStr(oClient.Username, "@") > 0 Then
      m_UserName = Split(oClient.Username, "@")
      m_User = m_UserName(0)
      m_Domain = m_UserName(1)

      ' Do stuff

      oMessage.Copy("Sent Items")

      ' More stuff

   End If
End Sub
SørenR.

Algorithm (noun.)
Word used by programmers when they do not want to explain what they did.

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

Re: Put a copy of outgoing emails to Sent folder.

Post by jimimaseye » 2016-05-16 14:08

The problem is that an ONACCEPTMESSAGE doesnt guarantee a delivery. What happens if a RULE intervenes and changes the message (or deletes it completely). Or the actual delivery doesnt get done (failed or redirected for somereason)? If you DO manage to get that copy in the SENT folder (which I doubt), it would be a false reflection.
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

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

Re: Put a copy of outgoing emails to Sent folder.

Post by jimimaseye » 2016-05-16 14:20

Dont work.

Code: Select all

"DEBUG"	2332	"2016-05-16 14:16:09.889"	"Executing event OnAcceptMessage"
"ERROR"	2332	"2016-05-16 14:16:10.268"	"Script Error: Source: Microsoft VBScript runtime error - Error: 800A000D - Description: Type mismatch: 'oMessage.Copy' - Line: 15 Column: 6 - Code: (null)"
"DEBUG"	2332	"2016-05-16 14:16:10.288"	"Event completed"
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