这是一个批量证书生成器/邮件程序包

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方法,以便我们在读取文件时捕获任何可能的错误
^{pr2}$

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”格式以获得更好的结果

  • 使用

    if mail.read_file('filename.csv'):
     mail.renderCertificate('certificateTemplate.png')
    
    Now如果您使用的是VS代码,那么效率会更高
    • 打开将在项目根目录上创建的文件夹名称仅渲染一个图像以供示例使用
    • 因为终端会提示您输入证书模板中文本的位置
    • 一定要试验你的值和字体大小
    • 一旦满意,当提示您为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

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java 401在API URL上带有声明性Http客户端,并带有@Secured(SecurityRule.IS_ANONYMOUS)注释   java如何在Android中创建计时器?   Java8WebStart安全弹出窗口   java会通过以下两种方式导致堆空间耗尽吗?   java项目调度GA:染色体的高效数据结构   java Apache POI:如何在Excel文件中插入列   java在JRE系统库中每个jar扮演什么角色   java如何在抽象类中执行@mock(不是注入mock)   java如何使用opensearch和Lucene发送搜索查询?   java在ApachePOI中处理空列   java广播接收器未接收到目标   java错误ELF类:ELF类64(可能原因:体系结构字宽不匹配)   java调用Web服务(SSL)时出错   用于iot集线器设备固件更新的java Rest API   通过xslt将xml转换为文本文件时引发java异常   Java linux打印问题   Java XML转换器重复行   java从另一个类的方法将数组导入mainActivity类   多线程选择与Java交互的线程   我想在java程序中打印以下格式的文件: