Setup Mail Sending
This guide will setup a fundamental server necessary, among others, for password recovery
and tasks notifications, which is the email server.
See also
SettingEnvironmentContactEmail for proper sender address setup.
Testing your configuration
On the server production
console run:
ActionMailer::Base.logger = Logger.new(STDOUT)
class Sender < ActionMailer::Base
def mail(to)
recipients to
from Environment.default.contact_email
reply_to Environment.default.contact_email
subject "test"
body render(:text => 'test')
end
end
Sender.deliver_mail('youremail@domain.com')
Or under
telnet localhost 25
HELO localhost
MAIL FROM: noreply@noosfero.net
RCPT TO: youremail@domain.com
DATA
Type message here.
.
QUIT
Servers
Exim4 (MTA)
Just install exim4:
sudo apt-get install exim4-daemon-light mailutils
Configure exim4 for Local Mail Service
dpkg-reconfigure exim4-config
At configuration helper,
(1st screen) choose the option for "internet site" and select "Ok" to continue.
(2nd screen) Enter your system's FQDN (fully qualified domain name) on the "mail name" configuration screen.
(3rd screen) Enter "127.0.0.1" when asked which IP address to listen on for SMTP connections.
(4th screen) Make sure you list your FQDN, hostname, and localhost entries when you're asked which destinations mail should be accepted for.
i.e.: myserver.example.com; myserver; localhost.localdomain; localhost
(5th & 6th screens) Leave the relay domains and relay machines fields blank. (except if you what you're doing)
(7th screen) Select "No" when asked whether to keep DNS queries to a minimum.
(8th screen) You may select either "mbox" or "Maildir" when asked about the delivery method used for incoming mail. While many utilities use mbox format, Maildir format can make handling individual locally delivered mail messages easier, and is widely supporting by a range of applications.
(9th screen) Accept the default "non-split" option for your mail configuration file.
Test your mail configuration. Issue the following command to send a test email, substituting an external email address for
someone@somedomain.com.
echo "This is a test." | mail -s Testing someone@somedomain.com
And make sure
config/local.rb file is empty.
Postfix (MTA)
...
Sendmail
You can use a local sendmail server to send emails. Note that may be dificult for emails servers
to accept these emails sent by sendmail using an internet IP address.
Add to
config/local.rb:
ActionMailer::Base.delivery_method = :sendmail
ActionMailer::Base.sendmail_settings = {
:location => '/usr/sbin/sendmail',
:arguments => '-i -t'
}
SMTP without security layer
Add to
config/local.rb:
ActionMailer::Base.smtp_settings = {
:address => "mail.mydomain.com",
:port => "587",
:domain => "mydomain.com",
:authentication => :plain,
:user_name => "USERNAME",
:password => "PASSWORD"
}
Note that the plugin showed below may conflict. You may uninstall it by
just removing its directory.
TLS based server
Let's setup using a Google Account and GMail SMTP server, although this guide should work
on any TLS based SMTP server.
It was based on
Douglas F Shearer's guide
You'll need to install a plugin for TLS support. Just run:
script/plugin install git://github.com/collectiveidea/action_mailer_optional_tls.git
Add to
config/local.rb:
ActionMailer::Base.smtp_settings = {
:tls => true,
:address => "smtp.gmail.com",
:port => "587",
:domain => "YOURDOMAIN",
:authentication => :plain,
:user_name => "GOOGLEUSERNAME",
:password => "GOOGLEPASSWORD"
}