How to send emails from CPanel email using python script - python

Hope you are doing well.
I am a developer that has not enough experiences in CPanel.
There are some problems to send email from CPanel and have tried a lot times but couldn't resolved, so I asked help of experienced veterans.
Recently days, I made simple project to send email in python and checked it on my local pc.
It worked well, so I posted it on CPanel, but some problems were occurred.
When I ran python code, it works without error but there is a problem for receiving.
I tested it with 2 kinds of email, one is outlook email, one is gmail.
First problem is a big latency. Outlook email was arrived after 2hours from I sent it in python. Also sometimes they was not arrived.
Second problem is occurred in gmail, gmail never arrives.
I searched many blog and post, but couldn't find solution.
Best similar contents is Sending emails from CPanel email using python script, but has not correct answer.
Additional
I use godaddy cpanel and can not use WHM. Also asked questions to support team before 4days, but they did not give me correct solution. Following image is a information that I used to send email.
I want to get the solution if I can send email directly to smtp.gmail.com on cpanel using python or if this is impossible, how to send email from ***#<domain.com> of cpanel to gmail accounts.
Thank you.

Related

Outlook Python script can't login into office.365 server

I have recently run into an issue with Outlook. I have been tasked with creating a python script that reads in emails from the office 365 server, using the imap-tools python library. I successfully setup and deployed the script. It was working fine until last week. The error given is:
"imap_tools.errors.MailboxLoginError: Response status "OK" expected, but "NO" received. Data: [b'LOGIN failed.']"
The code used to login is as follows:
username = os.environ["EMAILACCOUNT"]
password = os.environ["EMAILPASSWORD"]
server = "imap-mail.outlook.com"
from imap_tools import MailBox
MailBox(server).login(username, password, initial_folder="INBOX/my_folder")
Neither the login credentials nor the code changed at all, so I don't think those are the reasons for the script to break. I created a test email account, which was not attached to our company organization in outlook, and it worked with no issue. This leads me to think that there may have been an update to outlooks security settings specifically surrounding an organization. I have spent hours googling the issue with no luck. No one else seems to be reporting this problem, which yet again makes me think the error stems from an organizational setting. I've double checked and no organization setting was changed.
Any and all suggestions or hints as to what may be causing this problem would be greatly appreciated.
Thanks.
I have the exact same issue. Scripts were working fine until last week.
This reddit user with the same issue claims it is basic auth but I have not resolved it in my case even with IMAP enabled for that account: https://www.reddit.com/r/Python/comments/vobbaz/can_no_longer_log_into_o365_via_imap_using_imaplib/

Is there a method for automating emails with SMTP or otherwise?

I've been writing some python scripts in order to do some automation for my work. One of the scripts is intended to gather some test results, compile the string of results with a "message" string, and send it as an email every 12-24 hours (if there are results) to each individual who needs this information. Additionally, we're running this script on Linux; either in a Jenkins pipeline, or in a crontab (this script will most likely be run via crontab).
I was initially using gmail's SMTP server (smtp.gmail.com, port 587) to send these since we're working off of our own personal gmail server anyways, and it worked for a bit once I gave the script an "App Password" since it was a "less secure app" to Google. However, after about an hour of testing with it, Google disabled the account for spam. Any subsequent accounts I try to set up for the same purpose are disabled on the spot, as well (the moment I try to send an email with it, it's halted and disabled). It's been a few days since I requested reviews on both of the accounts; but I don't think they'll get back to me any time soon, nor will it be a result in my favor.
Since Google was no longer viable, I looked online and saw that there are plenty of SMTP hosting options available, but we're not looking for a paid service just to send an email once every few days or so. In terms of free options, I was able to find one other post related to PHP/Ruby sending emails without SMTP (Send email without external SMTP service), but if possible I'd like to keep this within Linux/Python only unless there is a simpler way, or a way that links well with Linux/Python. Even then, I'm still concerned that using SMTP is necessary for our gmail accounts to receive these emails. If I'm wrong, please correct me; because it certainly seems that way to me.
Based off of the situation, how could I adjust my strategy in order to automate email updates of this nature?

Openshift overrides email header 'from', 'reply-to' fields. How to send email without having to use SendGrid nor other paid email service.?

I have django 1.6 and python 2.7 deployed on Openshift. I notice that when the application sends emails out, Openshift overrides the email header by changing the 'From' field to 'no-reply#rhcloud.com' and ignore all 'Reply-to' field that has been set in the application.
I have searched around and it seems like Openshift overrides the email header and recommendation is to use their email service partner which is NOT FREE.
Is there any other way to avoid this ie. deploy Django application on Openshift while still having the application sends email as per dictated in the program. This exact program runs with no issues on test environment and localhost.
Any pointers are much appreciated. Thank you.
I myself is looking for free SMTP library to just send emails. So far not much luck.
Tried java embedded SMTP library Aspirin. I am able to send mails but not very comfortable working with it as I keep getting some unknown exceptions.
Apache James as another Java based SMTP server but don't think we can embed in the code yet.

How to send emails to a web application

I'm wondering how to achieve that nice feature I see on many websites today: when having conversations on social networks like Facebook or Linkedin, you can always answer an online message or status (which is not an email), by answering the email notification you receive. How do they achieve that?
As far as I can tell, I'd see two options:
Configure a mail server to fetch the emails and transmit the information to a Python (in my case) script to handle the data and save a database record that can be simply displayed afterwards on the website
Have a Python script running in the background, checking the mail server for incoming emails every few seconds (via pop3 or something)
Is there any other option? Has somebody already implemented this? What are the main pitfalls to look at? I'm asking this because I'd like to implement something similar on a web application I'm currently working on.
Thanks!
J
EDIT: I found this link which partially answers my question already: Django/Python: email reply is updated to site
I too am working on something similar and finding this https://github.com/pinax/django-notification useful. Check it out, you'll get an idea how to implement what you want.

How to avoid the "This message may not have been sent by" warning when sending email using Google App Engine?

I have a python GAE app that sends emails like in the example using the address of a registered administrator for the application as the "sender" address. When an email arrives from such an API call, here's a pic of the attached warning.
This message may not have been sent by: EmergencyButtonApp#gmail.com
Learn more Report phishing
Am I doing something wrong? None of the 3 options mentioned in the "Learn More" link are relevant I believe: the sender is a gmail address so the "SPF and DKIM authentication" solution isn't relevant, I'm not sending to a mailing list and I'm not using SMTP (I think, though maybe GAE is...).
Assuming you're seeing this in production, it's probably because you're claiming to be from a gmail address, but sending via App Engine. Use one of your app's email addresses as the sender (foo#yourapp.appspotmail.com) and it should work fine.
I think the best solution is to use Google's SMTP servers... It's the best way to not be considered as a spammer.

Categories