I would like to use ActionMailer to send emails from my rail app. I have an existing mail server that I would like to use, however it only supports SSL/TLS on port 465. It does not, however, support StartTLS (typically on port 587).
Can anyone suggest a way of achieving this? As far as I can tell there is no support out of the box for this. I am using Rails 3.0.7.
1 Introduction. Action Mailer allows you to send emails from your application using a mailer model and views. So, in Rails, emails are used by creating mailers that inherit from ActionMailer::Base and live in app/mailers. Those mailers have associated views that appear alongside controller views in app/views.
StartTLS is a protocol command used to inform the email server that the email client wants to upgrade from an insecure connection to a secure one using TLS or SSL. StartTLS is used with SMTP and IMAP, while POP3 uses the slightly different command for encryption, STLS.
Mail will automatically Base64 encode an attachment. If you want something different, encode your content and pass in the encoded content and encoding in a Hash to the attachments method. Pass the file name and specify headers and content and Action Mailer and Mail will use the settings you pass in.
Yes, you can specify the :ssl option.
Set the following values in your config/environments/production.rb
file:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'mail.example.com',
port: 465,
domain: 'example.com',
user_name: '[email protected]',
password: 'password',
authentication: 'plain',
ssl: true,
}
This works with my ISP (Bluehost) for sending mail.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With