Setting up mutt - exchange-server

I am a newbie to linux and need some help on using mutt for my office MS exchange server.
I have installed mutt 1.5.23 with configure options: --enable-imap --with-ssl and --enable-hcache.
I think, I am able to login to my exchange account, but can not go beyond (read or send mails). Mutt logs in and then says connection closed with message
--Mutt: (no mailbox) [Msgs:0] --- (date/date) ----------(all)
Is there a problem with my .muttrc or .msmtprc? I have no idea. I am pasting contents of both the files:
.muttrc:
source /usr/local/etc/Muttrc
set realname = "Ashish Goel"
set from = "ashish.goel#abc.com"
set envelope_from = yes
set imap_user = "ashish.goel#abc.com"
set folder = "imaps://owa.abc.com/owa/INBOX"
set imap_authenticators = "login"
set mbox = "imaps://owa.abc.com/owa/INBOX"
set spoolfile = "imaps://owa.abc.com/owa/INBOX"
set record = "imaps://owa.abc.com/owa/Sent Items"
set postponed = "imaps://owa.abc.com/owa/Drafts"
set copy=yes
set smtp_url = "smtps://ashish.goel#abc.com#owa.abc.com/owa"
mailboxes !
set header_cache = ~/.mutt/headers
set message_cachedir = ~/.mutt/cache/bodies
set certificate_file = /etc/ssl/certs
set imap_check_subscribed = yes
set imap_keepalive = 300
set imap_passive = no
set mail_check = 60
set timeout = 15
set sendmail = "/usr/bin/msmtp"
set ssl_verify_host = no
set ssl_verify_dates = no
.msmtprc:
account work
host owa.abc.com/owa
port 587
from ashish.goel#abc.com
user ashish.goel#abc.com
auth ntml
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile ~/.msmtp.log
ntlmdomain MYDOMAIN
protocol smtp
account default : work

I had this problem with an Exchange 2010 server both on this and later versions of mutt. In the end, I found the problem went away after I reset my subscribed folders in IMAP. I did this by using our web mail gateway which also uses IMAP. If you don't have such a facility, try the tips here to generate a list of subscribed folders, change it, and see if the updated list now works for you..

These are my functioning configuration files:
.muttrc:
set sendmail="/usr/bin/esmtp"
set envelope_from=yes
set realname="Kitone Elvis Peter"
set from="Kitone Elvis Peter <elviskitone#gmail.com>"
set use_from=yes
set edit_headers=yes
set smtp_url = "smtp://elviskitone#gmail.com#smtp.gmail.com:587/"
set smtp_pass =""
set imap_user = "elviskitone#gmail.com"
set imap_pass = ""
set mail_check = 30
set move = no
set imap_keepalive = 900
set header_cache = "~/.mutt/cache/headers"
set message_cachedir = "~/.mutt/cache/bodies"
set certificate_file = "~/.mutt/certificates"
set folder = "imaps://imap.gmail.com:993"
set spoolfile = "+INBOX"
I used esmtprc instead of msmtprc.
.esmtprc:
identity "elviskitone#gmail.com"
hostname "smtp.gmail.com:587"
username "elviskitone#gmail.com"
password ""
starttls required
You also need to enable IMAP on your email if you haven't already. Plus, you need to give access to insecure or third party applications on your email, in email settings.

Related

Getting network details from Active Directory in VB script?

There are needs when we want to populate user details from Active Directory. Sharing my code to access user details from AD.
Introduction
People often ask for querying active directory by passing network account name or email. There are many articles already available on this, and one might get confused. Here is simple working code to access user detail from active directory database-
Please note in order to access AD, you have to specify valid network account credentials in connection.
function GetADDetails(userId)
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.provider ="ADsDSOObject"
objConn.Properties("User ID") = "domain\userId" 'specify domain and
network account
objConn.Properties("Password") = "password" 'specify network password
objConn.Properties("Encrypt Password") = True
objConn.open "Active Directory Provider"
Set objCom = CreateObject("ADODB.Command")
Set objCom.ActiveConnection = objConn
strTarget="GC://abc.com" 'your domain name
objCom.CommandText ="select sn, givenName, sAMAccountName, name,mail,
telephoneNumber FROM '"+strTarget+"' where sAMAccountname='"+userId+"'"
Set objRS = objCom.Execute
If Not (objRS.EOF Or objRS.BOF) Then
GetADDetails=objRS.GetRows
Else
GetUserData = Null
End If
'Close objects and remove from memory
objRS.Close
objConn.Close
Set objRS = Nothing
Set objConn = Nothing
Set objCom = Nothing
end function

Refresh system variable using vbscript/QTP

I want to set system variable MQSERVER for connecting to MQ using QTP. Each time this value is changed from QTP, I need to restart QTP to reflect changes.
E.g. in the system variables window,
MQSERVER = ABCD
change the variable using
Set objWSH = CreateObject("WScript.Shell")
Set objSystemVariables = objWSH.Environment("SYSTEM")
objSystemVariables(MQVariableName) = MQVariableValue
The variable is set correctly but does not reflect in QTP code when connecting to websphere MQ.
Immediately when I restart QTP, the QTP reads the env variable correctly. Can you please let me know how I can use the below API method. I am getting type mismatch in QTP.
lnRetVal = SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, "Environment", 2, 1000, Null) 'Getting type mismatch here
Updating my original question with the code that connects to queue manager.
The very basic thing that I am trying to do is (which can't be done without restarting QTP)
1) Connect to a queue manager
2) Put the message
3) Connect to another queue manager
4) Read the output
Const MQOO_OUTPUT = 16
Const MQOO_INPUT_AS_Q_DEF = 1
Set MQS = CreateObject("MQAX200.MQSession")
Set QM = MQS.AccessQueueManager(Environment.Value("MQName")) 'This will pass the queue name and access the queue manager.
Set MQQueue = QM.AccessQueue(strQueName, MQOO_INPUT_AS_Q_DEF Or MQOO_OUTPUT)
Set PutOptions = MQS.AccessPutMessageOptions()
PutOptions.Options = MQPMO_NO_SYNCPOINT
Set PutMsg = MQS.AccessMessage()
PutMsg.CharacterSet = 1208
PutMsg.MessageData = PutMsgStr 'the message text
PutMsg.ApplicationIdData = "INTF_0439B"
MQQueue.Put PutMsg, PutOptions 'write the message to queue.
Also, my websphere MQ version is 7.0.1.8

Sending an email over TLS

I've try send email using TLS and port number is 587 with server name is smtp.gmail.com but always got error "error '8004020e'". I set SSL to false because the port 587 Authentication is TLS. Any wrong in my code?
Set objMail = Server.CreateObject("CDO.Message")
Set objConfig = CreateObject("CDO.Configuration")
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = false
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xx#gmail.com"
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "xx"
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objConfig.Fields.Update
Set objMail.Configuration = objConfig
objMail.From = "xx#gmail.com"
objMail.To = "yy#yahoo.com"
objMail.Subject = "Test EMAIL"
objMail.TextBody = "Test EMAIL"
objMail.HTMLBody = "fffffffffff"
objMail.Send
Set objMail = Nothing
Use port 465 instead and use ssl (smtpusessl = True) for Gmail or Amazon SES SMTP.
And also have to make sure (log in to the Gmail account mailbox, check if there are messages, that tell you about previous unsuccessful attempts) that the mailbox usage for the "old applications" are enabled... (it's a new "feature", that can be enabled on Yahoo and Google mail servers since not too long ago... Even maybe some mobile email clients will not work if this is not set.)

Managing remote DACLs on fileshares: Win32_ACE to Win32_Share

Goal: Add a local user account share-level Read/Write permissions to an existing file share.
I'm hitting a roadblock in developing this. Apparently Microsoft wants you to add your user's ACE to the DACL and then back into the security descriptor of the share. (1). (No, NET SHARE /ADD is not available for existing shares, I was surprised.)
In theory that should be simple enough, but my main fear is doing it wrong and losing the existing share permissions (lots of network users, specific groups). This solution needs to scale to a few thousand shares. I'm developing the solution to output data about the existing DACL in case I need to back out. I should write code to interpret that log and be prepared to add them back en-masse should anything go wrong.
At the moment I'm using VBscript-- I feel PowerShell might be a bit stronger of an approach but VBscript/WMI is a known quantity.
Research:
(1) http://blogs.msdn.com/b/helloworld/archive/2008/07/22/editing-share-permission.aspx
Copy the existing ACEs to an array:
rc = shareSec.GetSecurityDescriptor(sd)
ReDim acl(UBound(sd.DACL)+1) '+1 for the new ACL we're going to add
For i = 0 To UBound(sd.DACL)
Set acl(i) = sd.DACL(i)
Next
Add the new ACE to that array:
Set acl(UBound(acl)) = NewACE(NewTrustee(username, domain), 2032127)
The functions NewTrustee() and NewACE() encapsulate the instructions for creating the trustee and the ACE. The number is the access mask for Full Control.
Create a new security descriptor and assign it to the share:
Set sd = wmi.Get("Win32_SecurityDescriptor").SpawnInstance_
sd.ControlFlags = flags
sd.DACL = acl
rc = shareSec.SetSecurityDescriptor(sd)
Check this page for a lot more detail information about security descriptors, trustees, ACLs and ACEs.
Full script:
Const FullControl = 2032127
' modify these variables according to your requirements:
computer = "."
share = "..."
username = "..."
domain = CreateObject("WScript.Network").UserDomain
Set wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!//" _
& computer & "/root/cimv2")
Set shareSec = GetObject("winmgmts:Win32_LogicalShareSecuritySetting.Name='" _
& share & "'")
Function NewTrustee(name, domain)
Dim trustee, account
Set trustee = wmi.Get("Win32_Trustee").SpawnInstance_
trustee.Name = name
trustee.Domain = domain
Set account = wmi.Get("Win32_UserAccount.Domain='" & domain & "',Name='" _
& name & "'")
trustee.Properties_.Item("SID") = wmi.Get("Win32_SID.SID='" & account.SID _
& "'").BinaryRepresentation
Set NewTrustee = trustee
End Function
Function NewACE(trustee, permissions)
Dim ace : Set ace = wmi.Get("Win32_Ace").SpawnInstance_
ace.Properties_.Item("AccessMask") = permissions
ace.Properties_.Item("AceFlags") = 3
ace.Properties_.Item("AceType") = 0
ace.Properties_.Item("Trustee") = trustee
Set NewACE = ace
End Function
' copy existing ACEs
rc = shareSec.GetSecurityDescriptor(sd)
flags = sd.ControlFlags
ReDim acl(UBound(sd.DACL)+1) '+1 for the new ACL we're going to add
For i = 0 To UBound(sd.DACL)
Set acl(i) = sd.DACL(i)
Next
Set sd = Nothing
' add new ACE
Set acl(UBound(acl)) = NewACE(NewTrustee(username, domain), FullControl)
' prepare new security descriptor
Set sd = wmi.Get("Win32_SecurityDescriptor").SpawnInstance_
sd.ControlFlags = flags
sd.DACL = acl
' assign new security descriptor
rc = shareSec.SetSecurityDescriptor(sd)

VBScript Sending Email with High Importance

I used VBScript to write a function to send email automatically.
With .Configuration.Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "SMTPHOST.redmond.corp.microsoft.com"
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPAuthenticate) = cdoNTLM
.Item("urn:schemas:httpmail:importance") = sMailPriority
.Update
When I want to send email with high important, I set the sMailPriority to 2. When I test with the Gmail, it worked. But when I using outlook2010, it didn't work.
Some e-mail clients requires different headers to set e-mail priority.
Try to add all of these fields.
.Item("urn:schemas:httpmail:importance") = sMailPriority
.Item("urn:schemas:httpmail:priority") = 1 'sMailPriority
.Item("urn:schemas:mailheader:X-Priority") = 1 'sMailPriority

Resources