0

So I'm building a website using web2py and I've managed to figure out how to connect to a gmail account and send an e-mail.

from gluon.tools import Mail
gmail = Mail()
gmail.settings.server = 'smtp.gmail.com:587'
gmail.settings.sender = 'user1@gmail.com'
gmail.settings.login  = 'user1@gmail.com:pwd'
gmail.send( to= ['user2@gmail.com'] ,
            subject='Hello' , 
            message='world' )

Now when I send an e-mail this way instead of having "First name 1" as the sender when I get the e-mail in user2@gmail.com I get "user1" as the sender.

I'm guessing I need to do send something with the headers but have no idea what.

I can add headers like this:

gmail.send( to= ['user2@gmail.com'] ,
            subject='Hello' , 
            message='world' ,
            headers={} )

Let me know if you need additional info.

thank you!

web2py reference http://www.web2py.com/books/default/chapter/29/08/emails-and-sms

EDIT:

So I read a bit and this is related to something google does with regards to rewriting headers:

https://stackoverflow.com/a/1332803/1764089

However I'm massively confused because my google name is the one I'd like to use, but instead of the name it gets replaced with the email. Any ideas?

Also, I found this which may be useful but don't understand e-mails etc well enough.

https://support.google.com/mail/answer/13287

Community
  • 1
  • 1
evan54
  • 3,585
  • 5
  • 34
  • 61

1 Answers1

0

This isn't an exact answer, but for reference, check out this project I made on github for sending emails with a python script. (I added a tkinter UI).

https://github.com/paulkr/PyMail