Send email from the command line using PHP's smtp, mailgun, mandril or other drivers.
`email [email protected] --subject='Test Subject' --body='Test Body'`
Simply download the email.phar
and move to the location of your preference.
wget https://github.com/mreschke/email/raw/master/email.phar -O /usr/local/bin/email
chmod a+x /usr/local/bin/email
Then run /usr/local/bin/email
just once for the first time and it will
automatically create a user based configuration file in ~/.config/mreschke/email
which
you will need to edit with your mail driver and API keys.
If you prefer a global config file vs a user based config, simply sudo mkdir /etc/mreschke & sudo mv ~/.config/mreschke/email /etc/mreschke
. The email system will
always use the user config first if exists.
Run email
with no parameters to see help and usage information.
Email console command
Copyright (C) 2016 mReschke.com
This program may be freely redistributed under the terms of the MIT license.
Send email from the command line using PHP's smtp, mailgun, mandril or other drivers.
Options:
--to Add recipients (one or more --file or , separated string)
--cc Add cc recipients (one or more --file or , separated string)
--bcc Add bcc recipients (one or more --file or , separated string)
--subject Email subject
--text Email body (as text not html)
--html, --body Email body (as html)
--file Add attachment (one or more --file or , separated string)
--from Override from address defined in config file
--driver Override driver defined in config file
-v, --version Show version
-h, --help Show help and usage
If no --text, --html or --body is define, it will assume STDIN
Examples:
email [email protected] --subject='Hi' --body='Sup'
email [email protected] --subject='Hi' --text="$(cat /tmp/file.txt)"
cat /tmp/file | email [email protected] --subject='Hi'
uname -a | email [email protected] --subject='Hi'
email [email protected] [email protected] --subject='Hi' --body='There' --file=/tmp/file.txt
email [email protected],[email protected] --subject='Hi' --body='There'
email [email protected] [email protected] --subject='Hi' --body='There'
email [email protected] --subject='Hi' --body='There' --from='Me <[email protected]>'
email [email protected] --subject='Hi' --body='There' --driver=smtp
There is also a shorthand notation without using any -- (last file argument is optional)
email [email protected] 'Subject' 'Body Here'
email [email protected],[email protected] 'Subject' 'Body Here'
email [email protected] 'Subject' 'Body Here' /tmp/file.txt
email [email protected] 'Subject' 'Body Here' /tmp/file.txt,/tmp/file2.txt
Install https://github.com/box-project/box2 globally, then from the main email
directory (not src) run box build
. This creates a new ./email.phar
.