APIs & Integrations

Not applicable

Getting a "502 5.5.1 Unrecognized command" from the SMTP server

I’m trying to send an email with HTML contents, but I keep getting an error from the SMTP server:

502 5.5.1 Unrecognized command. W5plPbS5ppWV0f4b0-dD04 - hssmtp

Yet, the mail is sent, but with an empty body.

How can I debug what’s causing this?

This email body is the culprit, but we don’t know why: http://pastie.org/private/frdzpt8mcily31uxsufvkq

0 Upvotes
8 Replies 8
Not applicable

Getting a "502 5.5.1 Unrecognized command" from the SMTP server

Hi Mike.

It seems like your fix did the trick. We can now move forward with our tasks.
Thank you very much.

Not applicable

Getting a "502 5.5.1 Unrecognized command" from the SMTP server

Hi Mike.

Do you have any update regarding the script that my colleague sent you?

0 Upvotes
maxiak
HubSpot Employee
HubSpot Employee

Getting a "502 5.5.1 Unrecognized command" from the SMTP server

Sorry about the delay, I just got notified about this now. I’ll look into this and report back.

Best,
Mike

0 Upvotes
maxiak
HubSpot Employee
HubSpot Employee

Getting a "502 5.5.1 Unrecognized command" from the SMTP server

@repox @denizozsen Again, sorry for the delay, but I believe I fixed the underlying issue.
Let me know if you see it again. Also, I’ve added new logging to the service so if you give me the full message (including the ID), I can cross reference with some audit logs.

Best,
Mike

0 Upvotes
Not applicable

Getting a "502 5.5.1 Unrecognized command" from the SMTP server

Hi Mike,

Sure, here’s the test script we used. The body text in Repox’s pastie link should be in a file named body.html, in the same directory as the script. And you’ll need to add an include of the SwiftMailer autoloader.
I’ve used placeholders for the API token credentials here.
We’re using the following SwiftMailer version: Swift-5.4.3

$message = \Swift_Message::newInstance()
    ->setSubject('Test email')
    ->setFrom(['from@mail.com' => 'Name'])
    ->setTo(['to@mail.com' => 'Name']);

// The text from body.html reproduces the issue
$message->setBody(file_get_contents(__DIR__ . '/body.html'), 'text/html');

// However, sending with a simple text works just fine
// $message->setBody('Here is your mail', 'text/html');

$transport = \Swift_SmtpTransport::newInstance('smtp.hubapi.com', 587, 'tls')
    ->setUsername('username@hubid.smtp.hubspot.net')
    ->setPassword('password');

// Turn off certificate check, for testing purposes
$transport->setStreamOptions(array('ssl' => array('allow_self_signed' => true, 'verify_peer' => false)));

$mailer = \Swift_Mailer::newInstance($transport);

$result = $mailer->send($message);
var_dump($result);
0 Upvotes
Not applicable

Getting a "502 5.5.1 Unrecognized command" from the SMTP server

Hi Mike,

Thanks for your reply! I’m working on the same Hubspot integration project with Repox. Since he isn’t available at the moment, I’ll reply instead.

We’re using the PHP library SwiftMailer to send SMTP mail, and have successfully sent mails with the same body via some other SMTP servers. Perhaps there’s some problem with the specific combination of SwiftMailer + Hubspot + our particular options + data?

If you could make a simple test with SwiftMailer and our example body text, that would be really helpful. Otherwise I’ll give your suggestion of debug logging a go, when I have some time.

Best regards,
Deniz

0 Upvotes
maxiak
HubSpot Employee
HubSpot Employee

Getting a "502 5.5.1 Unrecognized command" from the SMTP server

Hi denizozsen,

Is there any chance you can give me a sample snippet of code so I know how you’re configuring SwiftMailer?

Best,
Mike

0 Upvotes
maxiak
HubSpot Employee
HubSpot Employee

Getting a "502 5.5.1 Unrecognized command" from the SMTP server

Hi Repox,

This is definitely worrying to hear, and I would like to get to the bottom of this. A few questions so we can figure this out:

  1. What are you using to send? Is this using a standard SMTP library?
  2. In this SMTP library, can you enable debug level logging to see what the SMTP exchange looked like?

If you can get the smtp debug logs, that would be tremendously helpful. Otherwise, if we can get the SMTP client library/language, I can try to reproduce it for you.

Best,
Mike

0 Upvotes