Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
content_object['mime_object'] = mime_object
return content_object
def feedback(self, message="Awesome features! You made my day! How can I contribute?"):
""" Most important function. Please send me feedback :-) """
self.send('kootenpv@gmail.com', 'Yagmail feedback', message)
def __del__(self):
try:
if not self.is_closed:
self.close()
except AttributeError:
pass
class SMTP_SSL(SMTP):
def login(self, password):
if self.port == '587':
self.port = '465'
self.smtp = smtplib.SMTP_SSL(self.host, self.port, **self.kwargs)
self.smtp.set_debuglevel(self.debuglevel)
self.is_closed = False
if not self.smtp_skip_login:
password = self._handle_password(password)
self.smtp.login(self.user, password)
parser.add_argument('-to', '-t', help='Send an email to address "TO"', nargs='+')
parser.add_argument('-subject', '-s', help='Subject of email', nargs='+')
parser.add_argument('-contents', '-c', help='Contents to send', nargs='+')
parser.add_argument('-attachments', '-a', help='Attachments to attach', nargs='+')
parser.add_argument('-user', '-u', help='Username')
parser.add_argument('-oauth2', '-o', help='OAuth2 file path')
parser.add_argument(
'-password', '-p', help='Preferable to use keyring rather than password here'
)
args = parser.parse_args()
args.contents = (
args.contents if args.contents else (sys.stdin.read() if not sys.stdin.isatty() else None)
)
if args.command == "oauth":
user = args.user
SMTP(args.user, oauth2_file=args.file)
print("Succesful.")
else:
yag = SMTP(args.user, args.password, oauth2_file=args.oauth2)
yag.send(
to=args.to, subject=args.subject, contents=args.contents, attachments=args.attachments
)
parser.add_argument('-attachments', '-a', help='Attachments to attach', nargs='+')
parser.add_argument('-user', '-u', help='Username')
parser.add_argument('-oauth2', '-o', help='OAuth2 file path')
parser.add_argument(
'-password', '-p', help='Preferable to use keyring rather than password here'
)
args = parser.parse_args()
args.contents = (
args.contents if args.contents else (sys.stdin.read() if not sys.stdin.isatty() else None)
)
if args.command == "oauth":
user = args.user
SMTP(args.user, oauth2_file=args.file)
print("Succesful.")
else:
yag = SMTP(args.user, args.password, oauth2_file=args.oauth2)
yag.send(
to=args.to, subject=args.subject, contents=args.contents, attachments=args.attachments
)
try:
if not self.is_closed:
self.close()
except AttributeError:
pass
class SMTP(SMTPBase):
def login(self):
if self.oauth2_file is not None:
self._login_oauth2(self.credentials)
else:
self._login(self.credentials)
class SMTP_SSL(SMTP):
def __init__(self, *args, **kwargs):
import warnings
warnings.warn(
"It is now possible to simply use 'SMTP' with smtp_ssl=True",
category=DeprecationWarning,
)
kwargs["smtp_ssl"] = True
super(SMTP_SSL, self).__init__(*args, **kwargs)