Write a mail wrapper The NetBSD Project
Status: Closed Time to complete: 240 hrs Mentors: Aleksej Saushev, Julian Coleman, Julian Fagir Tags: system, service, network, howto, sh, smtp

NetBSD, as almost all Unixes, brings a mailserver (Postfix) along with its standard system.
This mailserver is enabled by default to let outgoing mails through, but most mailservers won't accept mails from dial-up networks. So the most common way is to use another mailserver with your common mail account to relay mails.

Your task is to write a small wrapper that does the authentication needed for most SMTP relays, such that a user only has to insert his account details for e.g. Gmail and then can relay the system mails there.

You should also take into account relaying the system user's mails to that account or document how you would do so. This would entail (though this is not part of this task) having a configuration for several users, such that they can setup this for themselves without others seeing their password.
This task doesn't have to be necessarily code, a comprehensive guide on how to do this by hand would also be sufficient (but not obsoleting the coding task).

Uploaded Work
File name/URL File size Date submitted
smtp.py 554 bytes December 03 2012 00:23 UTC
aliases 182 bytes December 03 2012 00:27 UTC
README 366 bytes December 03 2012 00:32 UTC
RELAYING 984 bytes December 03 2012 22:07 UTC
RELAYING 984 bytes December 03 2012 22:18 UTC
smtp.py 802 bytes December 03 2012 22:18 UTC
John Grosen on November 27 2012 00:13 UTC Language?

What language would you want this to be in?

I don't have much experience with NetBSD, so I don't know what comes with the system (e.g. Python, Ruby).


John Grosen on November 27 2012 00:13 UTC Clarification

I mean programming language :P

Aleksej Saushev on November 27 2012 06:45 UTC Any reasonable one

NetBSD has only standard Unix languages (C/C++, AWK, sh) and Lua.

You may use Python or make another reasonable choice, if you want.

(You do not need to reimplement ESMTP and cryptographic software for this task.

In fact you're strongly advised not to do that, use some stock software.)

Matthew on December 2 2012 05:45 UTC Task Claimed

I would like to work on this task.

Aleksej Saushev on December 2 2012 12:25 UTC Task Assigned

This task has been assigned to Matthew. You have 240 hours to complete this task, good luck!

Matthew on December 3 2012 00:27 UTC Ready for review

The work on this task is ready to be reviewed.

Jeff Rizzo on December 3 2012 04:48 UTC Looking good thus far, needs some work.

Matthew asked me about this in #netbsd-code, and I looked at it.  The task itself is written confusingly, so I'm not sure what's missing.


His script (which claims python 3.2, but worked OK on 2.6) works well to forward a system user's email to an external address (which is one of the things described, I believe).


As far as relaying goes, that's not covered in the work done so far.  If I understand the intent of the task (and I'm not certain I do), you'll want to describe and/or script setting up a Postfix relayhost with authentication for sending *outgoing* email via a relay.

My recommendation (one of the other mentors please confirm) is to investigate "relayhost" and how you might set that up (with a script, or whatever) to use a gmail or other relay.

Julian Fagir on December 3 2012 21:42 UTC Task Needs More Work

One of the mentors has sent this task back for more work. Talk to the mentor(s) assigned to this task to satisfy the requirements needed to complete this task, submit your work again and mark the task as complete once you re-submit your work.

Matthew on December 3 2012 21:43 UTC Question

Do you mean Rizzo?

Julian Fagir on December 3 2012 22:01 UTC Two things

Sorry, I didn't send the text I wrote.

On the one hand, I wanted to second him. Please investigate how to use the "relayhost" configuration option in postfix (I'm sorry we didn't say that explicitly in the task description) and how to use it with smtp authentication. You should write a small howto to configure postfix to do this. You don't have to finish the script if you do this.

On the other hand, if you don't want to write the tutorial, you should add some error handling to your script. What happens if the smtp connection times out? What happens if the server does not provide SSL? What happens if the server has an unknown or wrong certificate?

Matthew on December 3 2012 22:18 UTC Ready for review

The work on this task is ready to be reviewed.

Julian Fagir on December 4 2012 15:46 UTC You forgot the README?

Ok, this looks even better. The RELAYING article was the one part of the task we mentioned.

I don't want to stretch this task too far, but could you please also insert a switch to either enable TLS or not? And maybe also add the possibility to use SSL, i.e. the connection is encrypted right from the beginning on, and not only after connecting to a plain-text host and issueing the which to use tls ("starttls")?

Apart from that, did you forget the README? You uploaded RELAYING twice, but you said in IRC you would upate the README as well.

After uploading the README, we will close this task (if you don't want to do the SSL part). But if we close it now, you couldn't upload further documents.

Matthew on December 4 2012 21:13 UTC Clarification

I meant that I would upload the RELAYING file not the README file.

Matthew on December 4 2012 21:15 UTC TLS

I thought smtp_use_tls would enable it. If you don't mind, I have another task that I would like to claim so unless I sound too impatient could you close the task?

Julian Fagir on December 4 2012 22:59 UTC Task Closed

Congratulations, this task has been completed successfully.