Yes, and the law is strict on this point. Direct marketing by automated calling machine, fax or email is prohibited when it uses the contact details of a person who has not given their prior consent to receive this type of message (art. 10).
The special case of email. Marketing by email remains permitted if your contact details were collected directly from you, in connection with a sale or a service, if it concerns similar products or services supplied by the same person, and if you are offered, expressly and simply, the possibility to object free of charge with each mailing (art. 10).
Your safeguards. In all cases, it is prohibited to send advertising messages without indicating valid contact details allowing communications to be stopped free of charge (art. 10). It is also prohibited to conceal the identity of the advertiser or to state a subject unrelated to the service offered (art. 10).
Finally, under the right to object, you may object free of charge to your data being used for commercial marketing purposes (art. 9).
This is general legal information, not legal advice. For advice on your specific situation, consult a lawyer admitted to the Bar in Morocco.