Cold emailing is legal. However, your emails and cold email software should comply with anti-spam laws and data regulations, like the GDPR or CAN-SPAM Act. For example, your emails should include an opt-out link for your recipients.