简体   繁体   中英

Sending emails from multiple email addresses via one SMTP server

I want to send emails from multiple email addresses like test@test1.com , sample@sample2.com via one smtp server that is against one email address. But when I do this I get following error:

raise SMTPAuthenticationError(code, resp) smtplib.SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8  https://support.google.com/mail/?p=BadCredentials

My SMTP settings are:

export CR_AUTH_MAIL_SERVER=smtp.gmail.com
export CR_AUTH_MAIL_PORT=587
export CR_AUTH_MAIL_USERNAME=testing@stackoverflowQuestion.com
export CR_AUTH_MAIL_PASSWORD=sampleForQuestion

If I use email address other than testing@stackoverflowQuestion.com , it is giving me error.

Can I send emails from multiple valid email addresses by using one email adresses? I'm always receiving emails from testing@stackoverflowQuestion.com .

You are using gmail SMTP which only has your testing@stackoverflowQuestion.com email id as valid email id with its respective password.

You can't send mail using gmail SMTP from an email id that doesn't exist or you don't have its right credentials. You would need to sign up with those email ids also.

You can try using self hosted mailer for this purpose (ie sending emails from different email ids but that isn't recommended and will fall into spam folders for being un-authenticated) Other quick solution would be to use some mail smtp providers like Mailgun, AWS SES etc. which will allow different "from" email ids.

Always test your mail score, in case sending marketing mail. This guide is quite helpful

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM