Sendgrid-python: Change default display name

Created on 3 May 2019  路  15Comments  路  Source: sendgrid/sendgrid-python

Issue Summary

I just want to change the display name of the sender's name.
for example, i have: [email protected]
The name displayed will be: Info.

I want a default name like: Assleek

  • django-sendgrid-v5==0.8.0
  • sendgrid==6.0.4
  • Python Version: 3.5
unknown or a question

Most helpful comment

Using ('mail', 'SENDER NAME') in the from_mail parameter works for me, as pointed by @thinkingserious.

Example:

message = Mail(
    from_email=('[email protected]', 'Custom Sender Name'),
    to_emails='[email protected]',
    subject='Subjet',
    html_content='<strong>Example</strong>')

All 15 comments

Hello @connelevalsam,

You can change the from email to be ('[email protected]', 'Example From Name'). Does that work for you?

With Best Regards,

Elmer

Thanks for your reply.

It still didn't change.
Here's my code:

send_mail('Request Accepted', reply, ('[email protected]', 'Smartalaba'), [mail], fail_silently=True)

Hello @connelevalsam,

Could you please provide me with the request body? Thanks!

With Best Regards,

Elmer

I don't really get how to do that

Hi @connelevalsam,

Please see this link: https://github.com/sendgrid/sendgrid-python/blob/master/TROUBLESHOOTING.md#viewing-the-request-body

Thanks!

With Best Regards,

Elmer

Okay Thanks
here it is:

Django version 2.1.7, using settings 'smartalaba.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: Request Rejected
From: ('[email protected]', 'Smartalaba')
To: [email protected]
Date: Tue, 02 Jul 2019 11:51:33 -0000
Message-ID: <156206829350.5016.2413891739432056265@DESKTOP-P6L8JP6>

It still doesn't show the name: smartalaba
instead shows info
why?

Using ('mail', 'SENDER NAME') in the from_mail parameter works for me, as pointed by @thinkingserious.

Example:

message = Mail(
    from_email=('[email protected]', 'Custom Sender Name'),
    to_emails='[email protected]',
    subject='Subjet',
    html_content='<strong>Example</strong>')

Yeah thanks

Yeah thanks

This should probably be added to the doc (readme) or a sample. The current sample for mail (https://github.com/sendgrid/sendgrid-python/blob/master/examples/mail/mail.py) just shows how to construct a body manually.

@coldice Feel free to add an example and I can review it.

@childish-sambino looking closer into it, I realized I was blind ;) - there is a good full example for all parameters at https://github.com/sendgrid/sendgrid-python/blob/master/use_cases/kitchen_sink.md and the main helper index page is listed in the mail example (L31) and in the main readme. I did not see that before, as I was just looking into the examples/mail folder.

So not sure if any change is required, maybe we could add a small sample pointing to the existing further samples. Something like this: https://github.com/coldice/sendgrid-python/blob/is-add-example/examples/mail/mail_helpers.py ?

@coldice Works for me. I can review a PR if needed.

This works well.
('your-email', 'SENDER NAME')

Using ('mail', 'SENDER NAME') in the from_mail parameter works for me, as pointed by @thinkingserious.

Example:

message = Mail(
    from_email=('[email protected]', 'Custom Sender Name'),
    to_emails='[email protected]',
    subject='Subjet',
    html_content='<strong>Example</strong>')

You can use like this:
from_email='name from@mail.com'

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DougCal picture DougCal  路  3Comments

ArchTaqi picture ArchTaqi  路  4Comments

thinkingserious picture thinkingserious  路  5Comments

hugomallinson picture hugomallinson  路  3Comments

thinkingserious picture thinkingserious  路  3Comments