0
votes

I am working on script to send emails. Emails are supposed to be send from a shared mailbox in outlook. This shared mailbox doesn't have a password and here is the trick: on the one hand I need the authenticate and provide a password, on the other hand I have no password to provide. I ran the scripted with my professional outlook mailbox (email address + password) and it works.

Here is my config:

MY_ADDRESS = "---emailaddressofthesender---"
PASSWORD = ""
MESSAGE = "some message"

# set up the SMTP server
s = smtplib.SMTP(host='smtp-mail.outlook.com', port=587)

s.starttls()
s.login(MY_ADDRESS, PASSWORD)

msg = MIMEMultipart()       # create a message

# setup the parameters of the message
msg['From']=MY_ADDRESS
msg['To']="---emailaddresseofthereceiver---"
msg['Subject']="This is TEST"

# add in the message body
msg.attach(MIMEText(MESSAGE, 'plain'))

# send the message via the server set up earlier.
s.send_message(msg)
del msg

# Terminate the SMTP session and close the connection
s.quit()

I tried:

  • Read the doc smtplib. Unless mistaken, I found no mentions about authentications without password.
  • PASSWORD = "": authentication error
  • PASSWORD = None: authentication error
  • s.login(MY_ADDRESS): PASSWORD argument is missing
  • remove s.login() method from the script: Client was not authenticated to send anonymous mail during MAIL FROM [PR0P264CA0184.FRAP264.PROD.OUTLOOK.COM]

The only working solution I have now is to send from my mailbox credentials and not from the shared mailbox. For the sake of this project, this solution is not acceptable.

Many thanks in advance for your help

1

1 Answers

0
votes

Add this right before the s.send() step and it will work.

s.SentOnBehalfOfName = 'SharedFolder'