APIs & Integrations

jmichaelTest
Member

Send email to multiple recipients from SMTP API

Hi,
How do I send email to multiple recipients using the SMTP API.

I specified two different emails in CC. But the actual email CC’ed to the FIRST email twice instead.

  1. Things I tried.
    a. I initially had abc@test.com; efg@test.com. And it CC’ed to abc@test.com twice.
14 Replies 14
maxiak
HubSpot Employee
HubSpot Employee

Send email to multiple recipients from SMTP API

Hi @jmichaelRS,

Sorry for the delay. I wanted to close the loop here and say the fix is out and you should no longer see duplicate Cc headers.

Best,
Mike

0 Upvotes
jmichaelTest
Member

Send email to multiple recipients from SMTP API

Thanks Mike. I was about to reach out to you today :slight_smile:

Thanks,
Johnson

0 Upvotes
maxiak
HubSpot Employee
HubSpot Employee

Send email to multiple recipients from SMTP API

Hey Johnson,

Glad to hear you’re making progress! I noticed that double Cc issue as well when testing. I’m going to get a test + fix out. If not today then hopefully by Monday. Will let you know when it’s out.

Best,
Mike

0 Upvotes
maxiak
HubSpot Employee
HubSpot Employee

Send email to multiple recipients from SMTP API

Hi @jmichaelRS,

Do you have an example proof of concept code? I suspect the issue is that, even though you have the multiple recipients in the headers, you’re not including them in the recipient list for the smtp conversation. For example, if you were using python, the following code wouldn’t work:

import smtplib
s = smtplib.SMTP('smtp.hubapi.com', 587)
s.login(USER, PASS)
s.sendmail("from@example.com", ["abc@test.com"], msg)

Instead, you need to include all recipients in the RCPT list above. E.g.:

import smtplib
s = smtplib.SMTP('smtp.hubapi.com', 587)
s.login(USER, PASS)
s.sendmail("from@example.com", ["abc@test.com", "efg@test.com"], msg)

Best,
Mike

0 Upvotes
jmichaelTest
Member

Send email to multiple recipients from SMTP API

Hi Mike,
Thanks for your clarification. I did some extensive test and research to test the various permutations of this issue. So, I got it to work finally in python.
Given below is the python code:
import requests
import urllib
import json
import smtplib

SMTP_USER = 'UserName’
SMTP_PASSWORD = ‘Password’

FROM_EMAIL = 'noreply@roofstock.com’
TO_EMAIL = 'to@xyz.com’
CC_EMAIL = [‘yyy@gmail.com’, ‘aaa@hotmail.com’, ‘bbb@gmail.com’]
BCC_EMAIL =[]
def send_test_email():
server = smtplib.SMTP(“smtp.hubapi.com”, 587)
server.starttls()
server.login(SMTP_USER, SMTP_PASSWORD)
msg = “From: {from_}\r\nTo: {to}\r\nCC: {cc}\r\nBCC: {bcc}\r\nSubject: {subject}\r\n\r\n{body}”.format(
from_=FROM_EMAIL,
to=TO_EMAIL,
cc=CC_EMAIL,
bcc=BCC_EMAIL,
subject=‘HubSpot SMTP API Test-3 CC’,
body=‘test email from Transactional Email Token’
)
server.set_debuglevel(1)
toaddrs=[TO_EMAIL] + CC_EMAIL + BCC_EMAIL
server.sendmail(FROM_EMAIL, toaddrs, msg)
server.quit()
print “Enqueued email send toaddrs: {toaddrs}, to: {to}, cc: {cc}, bcc: {bcc}, msg: {msg}”.format(
toaddrs=toaddrs,
to=TO_EMAIL,
cc=CC_EMAIL,
bcc=BCC_EMAIL,
msg=msg
)

send_test_email()

I was also able to get the CC working, i.e. send to multiple recipients on the CC list in C#.Net. I use the SMTP Client in C# to send emails. One Open issue though is the fact the email recipients in the CC list are duplicated when I use the SMTP client and HubSpot SMTP server. This is a HubSpot specific bug as I have tested with mandrill and writing to my local machine, and it works fine. I think it has something to do with the way HubSpot SMTP is parsing the CC email recipients. Attached is the images. If you need source code to test, I can send it separately.

Thanks a lot for your help.

Best,
Johnson

0 Upvotes
maxiak
HubSpot Employee
HubSpot Employee

Send email to multiple recipients from SMTP API

Hi @jmichaelRS and @pmanca,

The limitation you’re seeing is definitely not, by any measure, an intentional design decision. An SMTP relay must support Cc, Bcc and multiple recipients. I’m going to investigate today and see why you’re seeing what you’re seeing and get back to you.

Best,
Mike

0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

Send email to multiple recipients from SMTP API

@jmichaelRS The Single-Send API only allows one recipient at a time. If you have multiple ones you can loop through them in your code and call the Single-Send API multiple times.

0 Upvotes
jmichaelTest
Member

Send email to multiple recipients from SMTP API

Hi @pmanca,

FYI I am not using the single-send API, but rather the SMTP Api.

SMTP API Overview | SMTP API

The Deals API, along with the Companies API, has been exposed to allow for easy integration with the HubSpot CRM objects.

It’s a bummer that we cannot send to multiple recipients. Looping through the recipient list one at a time is not a viable solution because, the recipients would want to view the email as a single entity and also want to reply to the emails.
I am not sure why you would want to restrict recipients to a single recipient.

Thanks,
Johnson

0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

Send email to multiple recipients from SMTP API

@jmichaelRS Ah sorry I mixed up the two APIs there. Let me reach out and make sure the answer I gave you was true for the SMTP API as well.

0 Upvotes
jmichaelTest
Member

Send email to multiple recipients from SMTP API

@pmanca This seems to be a basic requirement. Any SMTP service should be able to sent emails to multiple recipients. Any idea why HubSpot is unable to do that?

0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

Send email to multiple recipients from SMTP API

@jmichaelRS The SMTP API is part of our Transactional email add on. Transactional Email by nature is a 1:1 relationship. A 1:many relationship would be a marketing email. This is set up on purpose given the intent of our SMTP API.

0 Upvotes
jmichaelTest
Member

Send email to multiple recipients from SMTP API

I understand transactional emails having a single recipient in the To list. But it is a genuine requirement to have multiple recipients in the CC list.
There are other marketing automation email vendors such as Mandrill, Sendgrid etc which allow multiple recipients for transactional emails.
Is there is a technical limitation on HubSpot other than the assumption that Transactional Email is by nature 1:1?

0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

Send email to multiple recipients from SMTP API

There is not a limit on the HubSpot side. This was a choice we made as we designed that part of our platform.

0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

Send email to multiple recipients from SMTP API

@jmichaelRS The SMTP API falls under the same rules as the Single-Send API where you can only send out to one email at a time.

0 Upvotes