Python Forum
Understanding The Arguments for SMTPlib - sendmail
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Understanding The Arguments for SMTPlib - sendmail
#1
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
Reply
#2
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
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
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?
Reply
#4
(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.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Sending Attachments via smtplib [SOLVED] AlphaInc 3 2,179 Oct-28-2021, 12:39 PM
Last Post: AlphaInc
  Sending random images via smtplib [SOLVED] AlphaInc 0 1,703 Oct-19-2021, 10:10 AM
Last Post: AlphaInc
  [UnicodeEncodeError from smtplib] yoohooos 0 3,405 Sep-25-2021, 04:27 AM
Last Post: yoohooos
  Understanding The Arguments for matplotlib.pyplot.plot JoeDainton123 0 1,938 Aug-19-2020, 01:19 AM
Last Post: JoeDainton123
  TimeOutError when trying to initiate smtplib.SMTP thecosmos 0 3,352 Jun-19-2020, 05:30 AM
Last Post: thecosmos
  SMTPlib help tpolim008 4 3,845 Apr-27-2020, 11:11 PM
Last Post: tpolim008
  smtplib: string formatting not carrying over to email ClassicalSoul 1 2,666 Apr-22-2020, 09:58 PM
Last Post: bowlofred
  Issue with text encoding ans smtplib.SMTP.sendmail() JustSomeUsername383 1 4,162 Jul-23-2019, 03:15 PM
Last Post: JustSomeUsername383
  smtplib mail without subject anna 2 2,488 Apr-24-2019, 05:44 AM
Last Post: anna
  Smtplib: What does context argument means? Pythenx 1 3,100 Mar-27-2019, 06:25 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020