These are questions that I occasionally get asked or I see pop up in a Google query string.
If you are trying to figure out something using Swaks, drop me a line at email@example.com. Swaks is a low-traffic project and I enjoy making it better, whether it's docs or code or just giving a hint in an email.
Multiple recipients can be specified by passing them as a single argument to the "--to" option. Any of the following will result in mail being sent to both firstname.lastname@example.org and email@example.com:
swaks --to firstname.lastname@example.org,email@example.com
echo "--to firstname.lastname@example.org,email@example.com" >> .swaksrc
swaks --config .swaksrc
The argument to the --to option is passed deep into the heart of Swaks with no real validation checking. This is done intentionally - because Swaks is meant to be a test tool, oddball values should be allowed. One side effect of this is that including a space after the comma will result in an email address that starts with a comma, which is probably not what you want.
There is one additional consideration here. Since Swaks is oriented around a single SMTP-session per invocation, it will only ever connect to a single server, even if multiple recipients are specified. In the example above, both emails will be delivered to the MX server for example.com (since, as documented, the mail routing for the last domain in the list is used). This may or may not work, depending on the configuration of email server you are testing.
Use the --add-header option:
swaks --add-header "X-Test-Header: foo"
There are lots more examples in the spec, look for --header and --add-header for details and nuance about each. A quick rule of thumb though is that you want --header to overwrite a header that already exists in your test email, and you want --add-header to add a completely new header, even if that same header already exists in your test email.
This really depends on what you want to do. At its base, Swaks is agnostic about what it sends in its DATA section, so you can craft whatever email you want and use it as the DATA of the message using the --data option. This is the best route for testing, where you usually have a fixed set of test cases to run, or you want to run the same command many times. If you don't know what a raw email looks like, send yourself an email to a Gmail account and select "Show Original". The entire text file is the format that the --data option expects (though it will probably be more complicated and have more headers than you need)
On the other hand, if you're trying to do something like use Swaks to send an email copy of a nightly HTML file, and you want the file to show up correctly in your MUA, Swaks does have a couple of helper options.
First, if you want the HTML file to be an attachment that can be openable or savable from your MUA, you want the --attach option. For instance, the following command will attach the file report.html. --attach-type is optional, but setting it will help your MUA know what to do with the attachment:
swaks --attach-type text/html --attach @report.html
Another interpretation of this question is "How do I send email which has an HTML-encoded body". This means sending an email that your MUA will display as HTML. The following should work.
swaks --attach-type text/html --attach-body @report.html
See the documentation for --attach-body for more information.
Swaks does not have the --bcc option so many people seem to be asking for lately. It may never get it, as it's not really true to Swaks' core functionality as a transaction tester, versus an MUA. That said, for those who really need this functionality, here's how to do it.
First, the reason you don't need a special option to do this:
So, to send a message to firstname.lastname@example.org and email@example.com, but only include firstname.lastname@example.org in the To: header (or, put another way, to BCC email@example.com), the following would work:
swaks --to firstname.lastname@example.org,email@example.com --header "To: firstname.lastname@example.org"
Yes, as of release 20120320.0! Woo!