Python Forum

Full Version: Understanding The Arguments for SMTPlib - sendmail
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello all

I am trying to understand how to input the different arguments for SMTPlib - sendmail.

I have the following code:-

From_Address = "From Email"
To_Address = "To Email"
Body = "This is the body of the email"

mail.sendmail(from_addr: From_Address, to_addrs: To_Address, msg = Body)

But i keep getting an error stating invalid syntax even though i have entered the semi colons exactly as the help pop up.

My question is how do you interpret the help pop up which shows the different arguments.

Can anyone help?

Thank you.

İmage
this
mail.sendmail(from_addr: From_Address, to_addrs: To_Address, msg = Body)
should be
mail.sendmail(from_addr=From_Address, to_addrs=To_Address, msg = Body)
that is assuming mail is smtplib.SMTP instance
buran

Thank you for the reply.

Your command:-

mail.sendmail(from_addr=From_Address, to_addrs=To_Address, msg = Body)
But when i open the brackets for this command a dialogue menu opens which shows the arguments and each argument as a : not a =, so would interpret all : as equals?
(Aug-02-2020, 07:42 PM)JoeDainton123 Wrote: [ -> ]But when i open the brackets for this command a dialogue menu opens which shows the arguments and each argument as a : not a =, so would interpret all : as equals?
It's not clear what you mean by "a dialogue menu opens"? Do you mean that you get some inetlisense hint as to what the arguments are expected?
Maybe look at basics as to how you pass [keyword] arguments to functions.