SMTP via GMAIL

binaryjesus coolman.guron at gmail.com
Sun Aug 3 02:28:46 EDT 2008


i have a lot of experience in gmail. i use it to store 100GB's of
server backup on it.

the form: field will be equal to the gmail acc u login with.

you are not clear with ur cc: so i cant offer any help on it. but u
can include multiple addresses in the To: and use Bcc:

since python doesnt include bcc in sendmail but there is a hacky
method to do that

to ='email at email.com \n\rBcc: email2 at gmail.com'
snedmail(from,to,mail)

this hack is also known as header injection attack



On Aug 3, 2:36 am, mmm <mdbol... at gmail.com> wrote:
> After reading about and using the smtplib module, I thought code such
> as below would ignore the 'Cc: ' body line below when sending messages
> and instead simply use the RECEIVERS list
>
> session = smtplib.SMTP(SMTPserver,port)
> session.set_debuglevel(1)
> session.ehlo(SMTPuser)  # say hello
> session.starttls()  # TLS needed
> session.ehlo(SMTPuser)  # say hello again
> session.login(SMTPuser, pw)
>
> FROM=SENDER
> RECEIVERS= (TO,CC)
>
> BODY= MakeBody(FROM,TO,CC,SUBJECT,MESSAGE)
> SMTPresult = session.sendmail(SENDER, RECEIVERS, BODY)
>
> Here the MakeBody() creates text like below
>
> From: FROM
> To: TO
> Cc: CC
> Subject: SUBJECT
>
> MESSAGE
>
> But when using smtp.gmail.com as the server I learned that any
> @gmail.com address in the  Cc: text block would
> receive mail even if I changed the code to have the RECEIVERS list to
> ignore the CC addresses or not include the gmail address in the CC
> list as below
>
> RECEIVERS= (TO,)
> BODY= MakeBody(FROM,TO,CC,subject,message)
> SMTPresult = session.sendmail(SENDER, RECEIVERS, BODY)
>
> Other @zzz.com CC addresses need to be in the RECEIVERS list however.
>
> Also the gmail server changes the  'From:  '  text to be the same as
> SENDER even if this is modified (a case not using FROM=SENDER.  I
> found other servers send mail that  displays the BODY specified From:
> address.
>
> Is this gmail specific or a quirk of the smtplib functions?
> I understand how Google might not want to send mail with FROM not =
> SENDER, but the CC behavior baffles me.
>
> And does anyone have a general routine that lets one also have Bcc:
> addresses usign SMTP?




More information about the Python-list mailing list