SASL Authentication Failed : Mutt - CPANEL - CentOS - centos

I'm trying to set a cron-job for sending mail attachments from my cpanel server.
I found that Mutt is a great option.
However, I'm having difficulty due to this one error that keeps occurring again and again.
Whenever I try sending a mail I get this:
SASL authentication failed.
Could not send the message.
The following is my .muttrc file.
set from = USERNAME#gmail.com
set realname = "NAME"
#set smtp_url = smtp://USERNAME#gmail.com:587/
set smtp_url = "smtps://USERNAME#smtp.gmail.com:465/"
set smtp_pass = PASS
set imap_user = USERNAME#gmail.com
set imap_pass = PASS
set folder = imaps://imap.gmail.com:993
set spoolfile = imaps://imap.gmail.com/INBOX
set header_cache = ~/.mutt/cache/headers
set message_cachedir = ~/.mutt/cache/bodies
set certificate_file = ~/.mutt/certificates
# Etc
set mail_check = 100
set move = no
set imap_keepalive = 900
set sort = threads
set editor = "vim"
#source ~/.mutt/gpg.rc
set ssl_starttls=no
set ssl_force_tls=yes
set smtp_authenticators = "login"
set ssl_verify_host = no
set ssl_verify_dates = no
This may take a long time (probably won't be solvable) and there might not be many people with this problem. But I feel that this thread might help others in the future
I've installed gnutils-bin and openssl
which gnutls-bin
/usr/bin/which: no gnutls-bin in (/usr/local/cpanel/3rdparty/lib/path-bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/cpanel/composer/bin:/usr/local/python3.6/bin:/usr/local/bin:/home/covid/.local/bin:/home/USERNAME/bin)
which openssl
/usr/bin/openssl

I ran into the same thing, I had to change my muttrc config so that set realname='name' was exactly the same as the Name in that is in gmails Personal Info for the account.
Also in Gmails Security "Less secure app access" needs to be set to ON

Just a quick update, according to google support for security reasons "Allow less secure apps" is no longer availabe (see here), however, there is still a workaround, please see below:
You might need to first enable MFA and then in your google account setting, under "Sign in to Google" select "App Passwords" (check out this google article if you don't see this option on your google account: 185833)

Related

MS AD2008 - Unable to force password change at next login using Perl Net::LDAPS and userAccountControl attribute

I am connecting to an Active Directory 2008 Domain Controller using perl Net::LDAPS and trying to set the "User must change password at next logon" account option and it's not working.
I am able to create, modify, delete, and move different objects but I am not able to get that change password setting to take!
This is what I am trying to do and it's not working:
Note: I am using a self written class wrapper for Net::LDAPS and the code below is boiled down to the bare bones of what I am trying to do.
# Binding to LDAP Directory:
$self->{LDAP_INSTANCE} = Net::LDAPS->new($host);
$self->{LDAP_INSTANCE}->bind(dn=>$dn, password=>$password, version=>3 )
my $rc =$self->{LDAP_INSTANCE}->modify(
$DN_OF_USER_ACCOUNT,
[ replace => [userAccountControl => 0x00800000] ]
);
print $rc->error; # Results in an empty string / No error
# Note: I have also tried: hex(800000) instead of 0x00800000 as well.
I am binding with a domain administrator account and I have verified that the $DN_OF_USER_ACCOUNT is correct.
The userAccountControl attribute is a bitfield with many settings. Changing the value for the user to be 0x00800000 would be quite harmful since it would remove the default of 0x200 ADS_UF_NORMAL_ACCOUNT.
The documentation for 0x00800000 is:
0x00800000 ADS_UF_PASSWORD_EXPIRED The user password has expired. This flag is created by the system using data from the Pwd-Last-Set attribute and the domain policy.
If we look at pwdLastSet's documentation, we see:
The date and time that the password for this account was last changed. [...] If this value is set to 0 and the User-Account-Control attribute does not contain the UF_DONT_EXPIRE_PASSWD flag, then the user must set the password at the next logon.
So to expire the password, we need to set pwdLastSet to zero. This is substantiated by a blog entry from Scripting Guy who does it in VBScript.
In Perl:
# Binding to LDAP Directory:
$self->{LDAP_INSTANCE} = Net::LDAPS->new($host);
$self->{LDAP_INSTANCE}->bind(dn=>$dn, password=>$password, version=>3 )
my $rc =$self->{LDAP_INSTANCE}->modify(
$DN_OF_USER_ACCOUNT,
[ replace => [pwdLastSet => 0] ]
);
print $rc->error;

Send an email from access via Lotus iNotes installed on intranet

I just need to be pointed in the right direction, on how
to send an email using VBA. I have Lotus as an email system which is embedded into our intranet system.
As a try, this code prepares an email and send it via Lotus (installed on pc) :
Dim ns As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim sender, recipient As String
'sender = Forms![LogIn]![TxtEmail]
If (Not IsNull(DLookup("Email", "Users", "UserName ='" & Me.Affectation.Value & "'"))) Then
recipient = DLookup("Email", "Users", "UserName ='" & Me.Affectation.Value & "'")
MsgBox "recipient *" & recipient & "*"
Else
MsgBox " recipient null"
End If
If Not (ns Is Nothing) Then
Call ns.InitializeUsingNotesUserName("CN=MyuserName/O=Cmpany", "password")
Set db = ns.GetDatabase("ServerName", "mail\MyuserName.nsf", False)
If (Not (db Is Nothing)) Then
Set doc = db.CreateDocument()
doc.Form = "Memo"
doc.SendTo = recipient
doc.subject = "Email Subject"
Dim rt As NotesRichTextItem
Set rt = doc.CreateRichTextItem("Body")
rt.AppendText ("Body text")
doc.Send (False)
Set rt = Nothing
Set doc = Nothing
MsgBox "Message Sent."
Else
MsgBox "db Is Nothing"
End If
Set db = Nothing
Set ns = Nothing
Else
MsgBox "ns Is Nothing"
End If
My question here is how set this code to make the target Lotus the one on our intranet: my login is such "39398C#mycompany.com" and the application is accessed by "http://mail.mycompany.com/mail/username.nsf..."
Unfortunately this is not possible this way. This "embedded" Lotus Notes as you call it is a simple website. It is called "iNotes" and does not have any dlls installed on your client (unless you install the ActiveX control for IE, but that does not help anything with your problem).
For sending eMails via iNotes you need a complete new method and you need your Domino administrator to help you with it: You could either use a webservice to send your mail (this has to be enabled on the server) or you can use DIIOP (again: DIIOP- Task has to be loaded on server).
To at least compose an email, you could use the mailto: protocol, but you need to set iNotes to be your mailto- protocol- handler:
Open Internet Explorer browser and log into iNotes (http://mail.mycompany.com/mail/username.nsf). Please note that this option is not available at this time to Firefox browser users.
Click the "Preferences" button located in the top right corner.
Find "Default Mail Client" section on the "Basics" tab of the iNotes preferences.
Click the button "Make Default".
Using this approach you cannot send the mail directly but need the user to press "Send".
I am not sure what you mean by "I have Lotus as an email system which is embedded into our intranet system".
You need the Notes client installed locally to be able to use COM in your own code. Use the ID file (must be local in the Notes Data directory) for your corporate account amd point to the server on the network for your mailfile.
But you can't point your program to a iNotes instance on a web server, it has to be on a Domino server accessed with a Notes client.
What you could do is to create a new web application on the server, where you have an agent that will read HTTP POST data, create an email and send it out.
Then you simply make a HTTP post from your application.
Here are a couple of blog entries I wrote that might help you:
http://blog.texasswede.com/free-code-class-to-read-url-name-value-pairs/
http://blog.texasswede.com/parse-url-in-domino-agent/
You should probably change your code to send mail via SMTP instead of using the Notes API objects. Microsoft provides an object model called CDO that I think will help you. See the answer to theis question for details. You will just need the hostname or IP address information to connect to a Domino server in your infrastructure that supports inbound SMTP.
Not sure about it, because that code is pretty old as we know use Outlook and I haven't use it in a long while, but that might be some insight :
I seem to remember that if you add doc.From = ns.CommonUserName, this will choose your session automatically!
And the full code :
Dim session As Object
Dim db As Object
Dim doc As Object
Dim attachme As Object
Dim EmbedObj As Object
Dim attachment() As String
Dim i As Integer
Set session = CreateObject("notes.notessession")
Set db = session.GetDatabase("", "")
Call db.OPENMAIL
Set doc = db.CreateDocument
With doc
.Form = "Memo"
.sendto = MailDestinataire
'.copyto = MailDestinataire2
.Subject = Sujet
.Body = CorpsMessage
.From = session.CommonUserName
.posteddate = Now
.SaveMessageOnSend = True
End With

Connecting to a K2 server without manually specifying username/password

The examples of connecting to a K2 server in the K2 developer reference like here and here all involve setting a username and password in the connection parameters. Using this approach would mean I'd need to store a password in either plaintext or at best using two-way encryption, which is obviously not good practice.
Is there an alternative way, perhaps using a token, to establish these connections? It's hard to believe that every app using this functionality just stores a password somewhere, there are obvious security implications to that.
Note - I am not a K2 API expert, but I've come across it as a product, and do know for sure that it natively supports Windows Authentication. The same page, for which you provided the link, states the following -
connectionSetup.ConnectionParameters["Authenticate"] = "true";
connectionSetup.ConnectionParameters["Host"] = "LOCALHOST";
connectionSetup.ConnectionParameters["Integrated"] = "true";
connectionSetup.ConnectionParameters["IsPrimaryLogin"] = "true";
//connectionSetup.ConnectionParameters["Originator"] = "false";
connectionSetup.ConnectionParameters["Password"] = "{YourPassword}";
connectionSetup.ConnectionParameters["Port"] = "5252";
connectionSetup.ConnectionParameters["SecurityLabelName"] = "K2";
//connectionSetup.ConnectionParameters["SecurityPackage"] = "Kerberos,NTLM";
connectionSetup.ConnectionParameters["UserID"] = "{YourUserName}";
connectionSetup.ConnectionParameters["WindowsDomain"] = "{YourDomain}";
The third parameter here is Integrated=true and while the documentation is not explicit about it, I'd recommend to use this parameter, and try connect while ignoring the user id and password. Assuming that K2 is configured for Windows Authentication, it should work without having to provide explicit user name or password.. and certainly without need to store them yourself as a client of K2.
You may use Integrated Security. K2 will then use the same user than the one currently logged in and you do not need to pass any credential.

Send mails from Notes - when it is not used for mail

Ok, in these times when some people move from Lotus Notes to Office 365 I have come across a certain requirement...
An older workflow application sends mail to users. This has worked fine for ages. But now we have a new type of users. These users are just using Notes for a couple of old legacy applications like the one in question.
The error we get is:
File does not exist
And the code that generates it is pretty simple:
Dim session As New NotesSession
Dim db As NotesDatabase
Dim rtitem As NotesRichtextItem
Dim doc2 As NotesDocument
Set db = session.CurrentDatabase
Set doc2 = New NotesDocument(db)
doc2.Form = "Memo"
doc2.Subject = "Test mail " & now
Set rtitem = New NotesRichTextItem (doc2, "Body" )
Call rtitem.AppendText("A simple test....")
Call rtitem.addnewline(2)
Call rtitem.AppendText("Link to complaint ")
Call doc2.Replaceitemvalue("sendto", "john#dalsgaard-data.dk")
doc2.Send( False )
It fails when running the last line....
So, the question really is: How can I code around the this issue?
I know there is no mail file for the user - and I would really prefer not to have to create one for the new users.
Thanks in advance!
/John
Error will appear when user triggering the code doesn't have a mail file specified in person document/location. One option would be to change code to save the new mail directly to server mail.box (assuming server is configured to route mails) or just send the email directly through SMTP using java.
Ok, I have done some trial & error testing on this....
Conclusion so far is that it works in this situation:
In the LOCAL location document (in names.nsf on the computer) you specify:
Mail server - as a server the user can reach
Mail "On Server"
An existing mail file - it can be ANY existing file on the server, it doesn't have to be a mail database.
Actually, a non-conclusive test indicates the mail database even doesn't have to exist (but the user with the setup for testing had to leave - so I couldn't confirm this tonight...)
Edit:
Further testing indicates that this may not be a problem if the user is NOT roaming. I need some further verification that this is actually the reason why I got it working (for one thing you cannot remove the mail file name again once added)... But thought I would add it here.

Setting up multiple email configurations in Code Igniter using config/email.php

I am using Code Igniter 2.0.3.
I am having various roles in my application and I want to set up various email configurations depending upon those roles.
As per this we can set up the configurations in config/email.php for one account, but I want to set up multiple accounts, so that depending upon the role I just call the role at run time and my settings are initialized automatically.
Sample code could be
$config['first_setting']['protocol'] = 'sendmail';
$config['first_setting']['mailpath'] = '/usr/sbin/sendmail';
$config['first_setting']['charset'] = 'iso-8859-1';
$config['first_setting']['smtp_user'] = 'j#j.j';
$config['first_setting']['wordwrap'] = TRUE;
$this->email->initialize($config['first_seeting']);
Gracias.
You don't need to use the config file to set the email class up.
When you "call the role" depending on the role it can set those settings at runtime with its own settings based on role data.
for example you'll have something like this:
function login(){
//do login stuff
//email settings for this user / role
$this->load->library('email'); //ensure its loaded
$conf['protocol'] = 'sendmail';
$conf['mailpath'] = '/usr/sbin/sendmail';
$conf['charset'] = 'iso-8859-1';
$conf['smtp_user'] = $this->session->userdata('email'); //user/role specific settings
$conf['wordwrap'] = TRUE;
$this->email->initialize($conf);
}
From there on out when you use the email class it will be sent using these settings. (provided you don't overwrite them latter)