Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To, ToName and Substitution values getting jumbled. #61

Closed
gs-spadmanabhan opened this issue Feb 26, 2015 · 16 comments
Closed

To, ToName and Substitution values getting jumbled. #61

gs-spadmanabhan opened this issue Feb 26, 2015 · 16 comments

Comments

@gs-spadmanabhan
Copy link
Contributor

Hi,

Currently the curl command which is getting framed by this framework is something like this
api_user=XXXXXX&api_key=XXXXXX&to[0]=[email protected]&to[1]=[email protected]&to[2]= [email protected]&toname[1]=sunand&toname[2]=sp&toname[3]=samosa&x-smtpapi={"sub":{"there":["Sunand Online","SP","Samosa Chat"]}}&subject=Hello there&text=Hi there&html=Hi there, How are you?&from=[email protected]

This is wrong, this is getting re-ordered at the sendgrid end it sends wrong Substitution values to recipients and also sets incorrect to and toname combination

The correct one is below, we should not specify to[1] and toname[1]
api_user=XXXXXX&api_key=XXXXXX&to[]=[email protected]&to[]=[email protected]&to[]= [email protected]&toname[]=sunand&toname[]=sp&toname[]=samosa&x-smtpapi={"sub":{"there":["Sunand Online","SP","Samosa Chat"]}}&subject=Hello there&text=Hi there&html=Hi there, How are you?&from=[email protected]

This should be fixed in buildingEmailBody.

@elbuo8
Copy link
Contributor

elbuo8 commented Feb 26, 2015

Do not use spaces inside your substitution tags, e.g. %first name%

On Thursday, February 26, 2015, gs-spadmanabhan [email protected]
wrote:

Hi,

Currently the curl command which is getting framed by this framework is
something like this
api_user=XXXXXX&api_key=XXXXXX&to[0]=[email protected]
javascript:_e(%7B%7D,'cvml','[email protected]');&to[1]=
[email protected]
javascript:_e(%7B%7D,'cvml','[email protected]');&to[2]=
[email protected]
javascript:_e(%7B%7D,'cvml','[email protected]');&toname[1]=sunand&toname[2]=sp&toname[3]=samosa&x-smtpapi={"sub":{"there":["Sunand
Online","SP","Samosa Chat"]}}&subject=Hello there&text=Hi there&html=
Hi there, How are you?&from=[email protected]
javascript:_e(%7B%7D,'cvml','[email protected]');

This is wrong, this is getting re-ordered at the sendgrid end it sends
wrong Substitution values to recipients and also sets incorrect to and
toname combination

The correct one is below, we should not specify to[1] and toname[1]
api_user=XXXXXX&api_key=XXXXXX&to[]=[email protected]
javascript:_e(%7B%7D,'cvml','[email protected]');&to[]=
[email protected]
javascript:_e(%7B%7D,'cvml','[email protected]');&to[]=
[email protected]
javascript:_e(%7B%7D,'cvml','[email protected]');&toname[]=sunand&toname[]=sp&toname[]=samosa&x-smtpapi={"sub":{"there":["Sunand
Online","SP","Samosa Chat"]}}&subject=Hello there&text=Hi there&html=
Hi there, How are you?&from=[email protected]
javascript:_e(%7B%7D,'cvml','[email protected]');

This should be fixed in buildingEmailBody.


Reply to this email directly or view it on GitHub
#61.

Yamil Asusta
@elbuo8 https://twitter.com/elbuo8

@gs-spadmanabhan
Copy link
Contributor Author

As you can see in the above curl request I am not using any spaces in Substitution tag (key name). In the request the key is "there" and values i am replacing with a text content which has space. Is that a problem?

@gs-spadmanabhan
Copy link
Contributor Author

I could see in the mail TO section, the to and to names are getting jumbled. AS for the substitution is concerned it doesn't have any problem.

@elbuo8
Copy link
Contributor

elbuo8 commented Feb 26, 2015

https://sendgrid.com/docs/API_Reference/SMTP_API/substitution_tags.html

Spaces are not allowed inside the values of the sub tags. The request will get messed up.

@gs-spadmanabhan
Copy link
Contributor Author

I tried without spaces in the values of sub tags as well. Please try it once from your end and let me know. I have forked your project and made the changes in buildEmailBody(Email) it seems to be working fine now. I can send you the pull request.

@alexleigh
Copy link

I'm also having an issue with the to[] and toname[] values getting jumbled. For example, the actual POST request that is generated by this library has the following segment:

--pom7ute_vZd8oSsyCEYWnbxy6GURKjC
Content-Disposition: form-data; name="to[0]"
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

[email protected]
--pom7ute_vZd8oSsyCEYWnbxy6GURKjC
Content-Disposition: form-data; name="to[1]"
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

[email protected]
--pom7ute_vZd8oSsyCEYWnbxy6GURKjC
Content-Disposition: form-data; name="toname[0]"
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

One
--pom7ute_vZd8oSsyCEYWnbxy6GURKjC
Content-Disposition: form-data; name="toname[1]"
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Two

However, the actual email that I receive on the other end has:
To: Two <[email protected]>, One <[email protected]>

This doesn't appear to be an issue with the sendgrid-java library, but rather something within SendGrid that is jumbling up the to and toname arrays. This may not be the best place to report it, but can someone forward it to the right party?

@gs-spadmanabhan
Copy link
Contributor Author

Do not fill values inside to[] and toname[] while framing post request body for sendgrid mail api. It will work as expected.

@gs-spadmanabhan
Copy link
Contributor Author

It's a bug in the library. I have forked the project and I have made
necessary changes.

Thanks & Regards,
Sunand P

“You have absolutely no idea how glad I am that I have no idea at all.”

On Fri, Mar 27, 2015 at 10:21 PM, Alex Leigh [email protected]
wrote:

I'm not filling in those values myself. The above request body was
generated by this library.


Reply to this email directly or view it on GitHub
#61 (comment)
.

@alexleigh
Copy link

Ah I see what you mean now, thanks. Could you tell me which commit in your fork contains the fix?

@gs-spadmanabhan
Copy link
Contributor Author

I will check-in my changes and let you know.

@gs-spadmanabhan
Copy link
Contributor Author

Here is the commit id,

gs-spadmanabhan@b0a4f03

@eddiezane
Copy link
Contributor

Would love it if you could create a PR with your changes! We'll get them tested and merged as soon as we can!

@gs-spadmanabhan
Copy link
Contributor Author

Just created a pull request, please check. Thanks!

@mikegreen
Copy link

Is there an update for this to get into the api as a fix?

@gs-spadmanabhan
Copy link
Contributor Author

I have submitted the pull request long back, still waiting for updates on the same.

@eddiezane
Copy link
Contributor

Sorry for the delay. The fix was merged and uploaded to maven central under v2.2.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants