这是一个批量证书生成器/邮件程序包
certificate-gen的Python项目详细描述
证书-生成者/邮寄者
这个软件包主要集中在创建批量证书并将它们邮寄给相应的应答者
安装
- 在
pip安装证书生成
在 - 此模块还使用库枕,不用担心,它将自动安装
此版本仅支持WINDOWS,我们正在开发它,使其可用于linux和mac os
请不要垃圾邮件这主要是为了发送有用的信息和使繁琐的任务更容易
预处理(用于发送邮件)
- 在
登录你的谷歌账户
在 - 在
[请单击此处启用较不安全的应用程序](https://myaccount.google.com/lesssecureapps)
在 - 在
确保您的CSV文件具有用于呈现证书的名称字段/用于发送电子邮件的电子邮件字段(如果没有,请确保将它们添加到CSV中)
在
使用
发送邮件的初始步骤
from certificate_gen import Mailer
#initialize an object for the Mailer class
mail = Mailer()
mail.username = '' #Your Gmail id / the id from which the mails should be send
mail.password = '' #Your Gmail Password
mail.subject = '' #Subject of the Mail
mail.body = '' #body of the Mail
一定要把上面提到的都填好
0)若要单独生成证书,请按照1-2中的步骤操作,并且不需要更改预处理过程中提到的任何帐户设置
1) 读取文件(确保只传递csv文件)
- 此函数还接受CSV和EXCEL文件,请随时提出问题请求:)
- 在
请在if块中传递read_file方法,以便我们在读取文件时捕获任何可能的错误
在
read_file方法中可能存在错误
- 有时csv文件的编码可能不匹配,您将收到错误提示,在read_file方法中传递编码格式
mail.read_file('filename.csv', encoding_f = 'latin-1')
- 在
您也可以尝试传递任何可用于csv_reader的编码格式,这些格式可在线用于PYTHON
在
1.1)您也可以通过向read_file方法传递可选参数来只读取邮件和名称
- 这只会使CSV文件中的电子邮件变红
在if mail.read_file('filename.csv', getNames=False ,encoding_f='latin-1'):
- 这将只读取CSV文件中的名称
在if mail.read_file('filename.csv', getEmails=False ,encoding_f='latin-1'):
- 在
默认情况下,将读取所有内容
在
2) 提供证书
- **预处理**
- 请确保您的证书模板位于程序的根目录中/或提供指向该模板的完整路径,并且Csv文件还具有name字段,并且您已使用read_file从Csv文件中读取该模板
- 在
证书模板的类型应为“.png”格式以获得更好的结果
在
- 在
使用
Now如果您使用的是VS代码,那么效率会更高if mail.read_file('filename.csv'): mail.renderCertificate('certificateTemplate.png')
- 打开将在项目根目录上创建的文件夹名称仅渲染一个图像以供示例使用
- 因为终端会提示您输入证书模板中文本的位置
- 一定要试验你的值和字体大小
- 一旦满意,当提示您为CSV文件中的所有名称创建证书时,按(1)
3) 现在,如果您的csv文件中有一个电子邮件部分,并希望发送邮件,请确保完成了最初的步骤
- 然后调用mail对象中的send_certificate_mail()方法
- 在
在if mail.read_file('filename.csv'): mail.renderCertificate('certificateTemplate.png') mail.send_certificate_mail()
3.1)可能的错误:
- 请正确输入您的邮件ID和密码
- 并遵循预处理
- 您将有一个邮件限制,如果进程因超出限制的错误而退出,请等待24小时,然后重新运行程序,(并确保您已删除以前的条目,系统将提示您有关在终端中发送的条目,您可以在那里参考)
4) 发送单个邮件:
from certificate_gen import Mailer
mail = Mailer()
mail.username = '' # Username
mail.password = '' # Password
mail.subject = '' # subject
mail.body = '''Body of the Mail'''
mail.attachment_path = 'sample_pic.png' # You can add attachments if you want to
mail.emails.append('') # For sending simple mails, just append the elements or simply target the object to a list of Email ids,
mail.send_mail_with_attachment() #If you have added attachments Please use this,
mail.send_mail() #Else this can be used to send single Mails
4.1)发送多封邮件:
from certificate_gen import Mailer
mail = Mailer()
mail.username = '' # Username
mail.password = '' # Password
mail.subject = '' # subject
mail.body = '''Body of the Mail'''
if mail.read_file('csv file path'):
mail.send_mail
- 项目
标签: