脚本宝典收集整理的这篇文章主要介绍了php – Python使用gmail从不同的地址发送电子邮件,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我知道PHP邮件程序库可以从任何人那里获取From地址而没有任何问题 – 但由于某种原因我不能在Python中.如果有帮助,我们有一个企业Gmail帐户.
这是我正在使用的代码
import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from email.MIMeimage import MIMEImage def senDFollowuPEmail(htML): msg = MimeText('body') msg['Subject'] = 'subject' msg['From'] = "THIS IS THE EMAIL I WANT TO CHANGE@domain.COM" msg['To'] = "client@client.com" username = 'accessaccount@gmail.com' password = 'password' server = smtplib.SMTP('smtp.gmail.com:587') server.starTTLs() server.login(username,password) server.sendmail(me,you,msg.as_string()) server.quIT() if __name__ == '__main__': sendFollowupEmail("test123")
这是@R_419_2493@,允许您从地址更改为您想要的任何内容
function sendFollowUpEmail($options) { /* * Send an email to a person or group. * Dependencies: @R_419_2493@Mailer * options: { * 'to' -> who to send the email to,* 'from'-> who the email was sent from,* 'subject'-> subject of the email,* 'body' -> the body of the email * } */ $host = 'smtp.gmail.com'; $username = "accessaccount@gmail.com"; $password = "password"; $port = 465; echo error_reporting(E_STRICT); require_once('@R_419_2493@Mailer/class.@R_419_2493@mailer.@R_419_2493@'); $mail = new @R_419_2493@Mailer(); $body = $options['body']; $mail->Issmtp(); $mail->IsHTML(true); $mail->SMTPAuth = true; $mail->SMTPSecure = "ssl"; $mail->Host = $host; $mail->Port = $port; $mail->Username = $username; $mail->Password = $password; $mail->SetFrom($options['from'],$options['from']); if($options['bcc']!='') { $mail->AddBCC($options['bcc'],$options['bcc']); } //$mail->AddReplyTo("name@yourdomain.com","First Last"); $mail->Subject = $options['subject']; $mail->AltBody = "To view the message,please use an HTML compatible email viewer!"; $mail->msgHTML($body); $address = $options['to']; $mail->AddAddress($address); $mail->send();
以上是脚本宝典为你收集整理的php – Python使用gmail从不同的地址发送电子邮件全部内容,希望文章能够帮你解决php – Python使用gmail从不同的地址发送电子邮件所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。