1

添付ファイルやテキストの画像などを含むメールを送信する機能はすでにプログラムしましたが、別のメールにコピーを送信するには、de Cc(カーボンコピー)機能を使用する機能が必要です。

関数にいくつかの変更を加えましたが、機能しますが、希望どおりではありません。

電子メールはアドレス( "toaddr")に送信され、メールにはCc( "tocc")電子メールとして追加された他の電子メールがあることが示されますが、Cc電子メールは電子メールを受信しません。

より明確にするために(私はあまり明確ではないと思うので)ここに例があります:

Sender: from@hotmail.com
Receiver: to@hotmail.com
Copied: cc@hotmail.com

to@hotmail.com receives the email and can see that cc@hotmail.com is copied on it.
cc@hotmail.com does not get the email.
if to@hotmail.com reply to all the email, THEN cc@hotmail gets the email.

関数で何を変更する必要があるかを誰かに教えてもらえますか?問題はserver.sendmail()関数にあると思います

これは私の機能です:

def enviarCorreo(fromaddr, toaddr, tocc, subject, text, file, imagenes):
    msg = MIMEMultipart('mixed')
    msg['From'] = fromaddr
    msg['To'] = ','.join(toaddr)
    msg['Cc'] = ','.join(tocc)         # <-- I added this
    msg['Subject'] = subject
    msg.attach(MIMEText(text,'HTML'))
    #Attached Images--------------
    if imagenes:
       imagenes = imagenes.split('--')
       for i in range(len(imagenes)):   
        adjuntoImagen = MIMEBase('application', "octet-stream")
        adjuntoImagen.set_payload(open(imagenes[i], "rb").read())
        encode_base64(adjuntoImagen)
        anexoImagen = os.path.basename(imagenes[i])
        adjuntoImagen.add_header('Content-Disposition', 'attachment; filename= "%s"' % anexoImagen)
        adjuntoImagen.add_header('Content-ID','<imagen_%s>' % (i+1))
        msg.attach(adjuntoImagen)   
    #Files Attached ---------------
    if file:
       file = file.split('--')
       for i in range(len(file)):
        adjunto = MIMEBase('application', "octet-stream")
        adjunto.set_payload(open(file[i], "rb").read())
        encode_base64(adjunto)
        anexo = os.path.basename(file[i])
        adjunto.add_header('Content-Disposition', 'attachment; filename= "%s"' % anexo)
        msg.attach(adjunto)
    #Send ---------------------
    server = smtplib.SMTP('localhost')
    server.set_debuglevel(1)
    server.sendmail(fromaddr,[toaddr,tocc], msg.as_string())    #<-- I modify this with the tocc
    server.quit()
    return
4

1 に答える 1

4

sendmailの呼び出しで[toaddr, tocc]、リストのリストであるパスを渡しますが、toaddr + tocc代わりにパスを試しましたか?

于 2012-04-25T19:30:49.410 に答える