Hot answers tagged

33 votes
Accepted

Accurate email syntax validation (no seriously)

"@"@example.com and "\ "@example.com both fail, but they are valid. ...
rhino's user avatar
  • 470
24 votes

Accurate email syntax validation (no seriously)

Said this in chat already, but @ succeeds even although it is not a valid email address. You should require at least 1 character in the local part and 1 character ...
Pimgd's user avatar
  • 22.3k
24 votes

Accurate email syntax validation (no seriously)

I personally find it hard to fault your code. Actually I'm quite surprised about the absence of code. Other than a few PEP8 errors there are three changes that I would recommend. You remove both <...
Peilonrayz's user avatar
  • 42.7k
22 votes
Accepted

Send daily email alerts of the Bitcoin Price

Define some constants I'd make some constants and put them at the top of the program because if your program becomes bigger, it'll be harder to change their values: ...
Grajdeanu Alex's user avatar
17 votes

Accurate email syntax validation (no seriously)

You seems to build your module to contain only validate as "public" function. You may want to enforce that by declaring ...
301_Moved_Permanently's user avatar
16 votes

Send daily email alerts of the Bitcoin Price

It seems to me that running a specific command at a specific time each day is more the job of a cron daemon than of said command. As such, I would simplify the ...
301_Moved_Permanently's user avatar
13 votes

Telling me what lesson I have tomorrow and emailing me the results

I would change the data organization to be the opposite way, to have a dict mapping to the two week types containing a dict with a mapping from the weekday to the lessons: ...
Graipher's user avatar
  • 40.9k
12 votes

Accurate email syntax validation (no seriously)

The code that you've written is generally really good, but as you seem to have found parsing non-trivial strings starts to get kind of complicated, and has all sorts of room for nasty edge cases. Your ...
ymbirtt's user avatar
  • 840
12 votes
Accepted

Analyze frequency and content of political fundraising E-mails

Let's start with the obvious: this code doesn't run. You're missing ans = starter() so that further (el)if ans.lower() == ... ...
301_Moved_Permanently's user avatar
11 votes
Accepted

Are your servers down...?

I'll proceed top to bottom. mail_error Which would you rather read: x.body = e.message or ...
200_success's user avatar
10 votes
Accepted

Replace many Outlook email rules with a script

Here's some changes I would make. First thing I would do is make most of this module level variables, initialized in your Application_startup method, and taking advantage of WithEvents to setup the ...
enderland's user avatar
  • 1,736
10 votes
Accepted

Sending text and HTML email using smtplib & MIMEText

The goals of this will be to make the code more readable and maintainable. Don't put templates and credentials in your code. Most of the class-level declarations of ...
Snowbody's user avatar
  • 8,442
10 votes
Accepted

Python program that obfuscates an email address

The code is straightforward and reads well, but: string concatenation is not very efficient, especially in a loop. You'd be better off using str.join on an ...
301_Moved_Permanently's user avatar
9 votes

Email checker ('@' sign, provider, domain extension)

My first comment would probably be that you shouldn't try to validate emails beyond checking that they have at least one character before an @ sign, one ...
Dan Oberlam's user avatar
  • 7,764
9 votes
Accepted

Simple email validation script

Interface design The current design of the validator class is not very intuitive. Users of this class must call the check_for_symbol and ...
janos's user avatar
  • 111k
9 votes
Accepted

Verifying user accounts on SMTP servers

What you really want is a robust argument parsing. This calls for argparse: ...
Graipher's user avatar
  • 40.9k
9 votes
Accepted

Bash script to truncate subject line of incoming email

Be sure to read the relevant RFCs that govern e-mail headers! Specifically: RFC 2822, Section 1.2.2: Header names are case-insensitive. RFC 2822, Section 2.2.3: Header fields may be line-folded: 2....
200_success's user avatar
9 votes
Accepted

Weekly MySQL database backup

Overall This is totally decent code and not too difficult to maintain. Your variable names make sense and you've made some effort at not repeating yourself, other than the lack of a loop which you ...
chicks's user avatar
  • 2,855
8 votes

Replace many Outlook email rules with a script

Setting up Outlook ...
Vogel612's user avatar
  • 25.2k
8 votes

Replace many Outlook email rules with a script

I'm too new to comment and I'm not sure this qualifies as an answer, but there are a couple changes I'd suggest: Consider removing the conditions (from, subject-contains, etc.) from the "executing" ...
Zac's user avatar
  • 81
8 votes
Accepted

C# SMTP notifier client

I believe I would take the Notifier constructor and pass in both the Port & Host information. When I instantiate the class I would pass these values in. Good idea. Both the ...
Konrad Morawski's user avatar
7 votes
Accepted

Counting e-mails in a mailbox for each hour

Formatting Please follow PEP8, the Python style guide. Most noticeably, use 4 spaces to indent. Working with files The recommended way to work with files is using ...
janos's user avatar
  • 111k
7 votes

Accurate email syntax validation (no seriously)

Instead of reviewing your code, I looked at your tests. You do not seem to support IPv4 mapped IPv6 addresses: validate('hello@[::FFFF:222.1.41.90]') (See http:/...
Sjoerd Job Postmus's user avatar
7 votes
Accepted

Using SendAsync to send multiple emails

From the SendAsync docs: After calling SendAsync, you must wait for the e-mail transmission to complete before attempting to send another e-mail message using Send or SendAsync. So no, this ...
RubberDuck's user avatar
  • 30.8k
7 votes
Accepted

E-store automatic email send, to be run daily

There are good and bad things about the code, but I will focus on some things that I believe to be bad about the code. The EmailSenderProgram namespace should be ...
gamesmad's user avatar
  • 336
7 votes

Bash script to truncate subject line of incoming email

Generally good code - plus points for good use of stdout/stderr and exit status. Shellcheck reported some issues: ...
Toby Speight's user avatar
7 votes
Accepted

Function to send email, refactored based on SOLID principles

I'd still say that you should break apart the mail message and SMTP client into separate classes for the "Single responsibility principle". In specific: A class should only have a single ...
dmoonfire's user avatar
  • 411
6 votes
Accepted

Colored <hr> in emails

Email formatting is very archaic Like, stone-age archaic. Like, HTML 4 but with most of the "cool" things (like <style> blocks and separate CSS ...
Phrancis's user avatar
  • 20.4k
6 votes

Analyze frequency and content of political fundraising E-mails

Setting aside PEP 8 (official style guide) issues I would make the following change: Rather than keeping your politician bins, names and email addresses in separate data structures (the only way they ...
Hari's user avatar
  • 161
6 votes

Analyze frequency and content of political fundraising E-mails

Imagine how much of a pain it would be to add another politician to this list. In addition to the Politician class suggested in another answer, I would suggest ...
Jared Goguen's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible