When sending emails via SMTP, the emails are not automatically saved to your "Sent" folder. This is because:
- SMTP only handles sending emails, not folder management
- Each email provider has different folder structures
- The sent folder requires IMAP access to save messages
The email sender now attempts to save sent emails to your IMAP sent folder automatically. This works if:
- Your monitoring email and sending email are the same account
- You have IMAP credentials configured in your .env file
- Your email provider allows IMAP append operations
If using Gmail:
- Gmail automatically saves emails sent from the same account to "Sent Mail"
- Make sure your SMTP_USERNAME matches your monitoring EMAIL_ADDRESS
- Gmail handles this automatically when authenticated properly
Add a BCC to save copies of sent emails:
# In email_sender.py, add to message headers:
message['Bcc'] = self.from_address- Create a folder in your email client called "Sent Orders"
- Set up a rule to move emails:
- FROM: your-sending-email@gmail.com
- TO: cs@company.com OR laticrete-cs@company.com
- ACTION: Move to "Sent Orders" folder
The system already logs all sent emails. You can find them in:
- Log file:
email_processor.log - Search for "Successfully sent order email"
-
If using different accounts for monitoring and sending:
- The sent email will appear in the SENDING account's sent folder
- Not in the MONITORING account's sent folder
-
Gmail settings to check:
- Enable "Show in IMAP" for Sent Mail folder
- Settings → See all settings → Labels → Show in IMAP
-
Check your IMAP folder names:
# Run this to see your folder names: import imaplib imap = imaplib.IMAP4_SSL('your.imap.server') imap.login('email', 'password') print(imap.list())
-
Common sent folder names:
- Gmail:
[Gmail]/Sent Mail - Outlook:
Sent Items - Yahoo:
Sent - Others:
INBOX.SentorSent
- Gmail:
For best results:
- Use the same email account for both monitoring (IMAP) and sending (SMTP)
- Ensure all credentials in .env match:
EMAIL_ADDRESS=monitor@gmail.com SMTP_USERNAME=monitor@gmail.com # Same as EMAIL_ADDRESS - The system will automatically try to save to sent folder
To verify emails are being sent:
- Check the recipient's inbox (CS_EMAIL)
- Check your email provider's sent folder via web interface
- Review the log file for confirmation
- Check your SMTP account's sent folder (if different from monitoring account)