Command Line Import

Your software
My Mautic version is: 2.15.x
My PHP version is: PHP Version 7.2.24-0ubuntu0.18.04.1

Your problem
My problem is:
I would like to import a list of DONOTCONTACT into my Mautic using a cronjob.
My file would contain two columns: “email”, “DONOTCONTACT”

I am already using mautic-custom-import-bundle to import my system info into Mautic, so cannot use this as well.

These errors are showing in the log:

Steps I have tried to fix the problem:

bumping this up… would appreciate any direction here.

It is unclear what you want to achieve or what the issue is.
You can just import the list to a segment…

Hey Yosu,

Thanks for the reply. Let me try and explain myself a bit better.

I am running multiple instances of Mautic and would like to centralise my DONOTCONTACT list automatically.

So what I have done is write a small bash script triggered by a cronjob, so each day the script connects to Mautic mysql, extracts the DONOTCONTACT from the table lead_donotcontact and saves this into a file. I then run a sftp cronjob to transfer this from my different Mautic instances to a central instance, and on this central instance (example Mautic1) I want to automatically import these contacts and flag them as DONOTCONTACT.

Now as I have mentioned there is a plugin that does this for you, however I am already using this plugin to automatically import data from my program platform into Mautic, and the limitations on this plugin is you can only have one type of mapping.

So my question is - is there a way to automatically import a file (csv) from the command line into Mautic, do I have to setup mapping ?

Does this make more sense to you ?

Yes there is a cronjob for importing contacts, you just need to add the csv file on the right folder…

mautic:import

Here’s the full list of cron jobs and what they do:

Try column doNotEmail for do Not Contact flag

https://www.mautic.org/docs/en/contacts/import.html

Then you should see field with same name for DNC processign

Hi Guys,

Thanks for the help. However I am still unable to wrap my head around this. I ran a test and created a file with the following:

Email,doNotEmail
test1@gmail.com,TRUE

I already had a contact in Mautic with test1@gmail.com

I then put this file in /var/www/mautic/app/cache/import/

and then ran the following two cronjob:
sudo php /var/www/mautic/app/console mautic:import:directory
sudo php /var/www/mautic/app/console mautic:import

The result was 1 inserted and 1 ignored, and then it added a records in contacts
Name = test1@gmail.com True and nothing else.

It did not merge the contacts and add the DNC flag to it.

bumping this up again, maybe one of the previous contributors can shed some light on this matter. I am sure the user case could be good for others.

doNotEmail should be 1 or 0
not TRUE

It works with TRUE.

Email needs to be lowercase though.

Example:
email,doNotEmail
test1@gmail.com,TRUE

1 Like

Hi

I am still getting the same results, and going crazy pulling my hair out as to what the problem is.

I have done it with both TRUE and 0/1 and each import simple pulls in my line from csv into name. It does not update the specific record.

Can you confirm that you have done this via command line using app commands

It worked for me.

I downloaded the 1.0.4 release, extracted it, renamed it and placed it in the /apps/plugins/ directory. I deleted the cache, configured the CustomImport features section and enabled the plugin.

I put a test.csv file with a dummy contact in /apps/cache/imports/.

I ran php7.2 console mautic:import:directory and php7.2 console mautic:import.

This is the result.

The new contact was added successfully with DNC set.

Addendum:

I even added a new csv with the contact details for DNC set to 0, false and blank. In each instance, it removed the DNC.

Hi MxyzptlkFishStix,

Thanks for the reply however I think you might have missed my initial post. I already use Mautic-custom-import-bundle:
" I am already using mautic-custom-import-bundle to import my system info into Mautic, so cannot use this as well."

This works great and I use it to bring in platform information into Mautic.

I am looking for an alternative method to import WITHOUT using the custom-bundle, as the limitation of custom bundle is that you can only use one template file.

I used an instance of Mautic without the plugin and it added DNC and removed it. I tested it with true/1 and false/0/(blank).

Thanks for the help. I still am unable to get it to work :frowning:
I have done exactly what you are explaining and still on the update all I am getting is under name the email and (1/0/TRUE). It is not updating the specific record, rather just adding a new one.

Is Email, under Custom Fields, set to Publicly Updatable?

Hey,

I got so excited when I saw your last post as it was not set to Publicly Updateable. So I went ahead and did what you suggested:

Then I went and created a record to test in mautic:

Next I created the file to import:

Then went ahead and ran the imports:

This is the output I got in Mautic:

So went ahead and made a file with doNotEmail blank and this was the result:

Feeling a little dumb at the moment as I am sure I am missing something so small.

I had a look at your screenshot and wonder what the results were in Mautic as the output of the results says: “2 lines were processed, 1 items created, 0 items updated, 1 items ignored in 0.142 s”. which makes me wonder if you get the same results I am seeing.
The actual import command works, but even on yours it created a NEW record and did not update any existing records.

Looking forward to hearing back on this issue

Publicbly updatable should be set to the default of No. Sorry that I wasn’t clear on that.

Contact added from import with DNC enabled/disabled via import.

Contact added in Mautic first and DNC enabled/disabled via import.

Is that an empty line at the top of your file?

Hi,

No there is not another line in the file.