Comments (3)
Both ways should work. This works too in the example I gave:
mail(to: to).attachments["appointment"] = { mime_type: "text/calendar", content: cal.to_ical }
Anyway, I'm glad you solved the issue!
from postmark-rails.
@akaspick I can't replicate the issue. I am able to send emails with iCal attachments and here's what I did:
- I created a new branch new Rails 7 app
- Added
postmark-rails
andicalendar
toGemfile
- Set up environment following environment variables:
export POSTMARK_SERVER_TOKEN=<YOUR TOKEN>
export DEFAULT_FROM=<YOUR FROM EMAIL ADDRESS>
export DEFAULT_TO=<YOUR TEST TO EMAIL ADDRESS>
- Added following to the
config/application.rb
:
config.action_mailer.delivery_method = :postmark
config.action_mailer.postmark_settings = { api_token: ENV.fetch("POSTMARK_SERVER_TOKEN") }
- Added a new mailer:
bin/rails g mailer Test email_with_attachment
# app/mailers/test_mailer.rb
class TestMailer < ApplicationMailer
default from: ENV.fetch("DEFAULT_FROM")
def email_with_attachment(to: ENV.fetch("DEFAULT_TO"))
@greeting = "Hi"
# Create a calendar with an event (standard method)
cal = Icalendar::Calendar.new
cal.event do |e|
e.dtstart = 1.day.from_now + 1.hour
e.dtend = 1.day.from_now + 3.hours
e.summary = "Some event"
e.description = "With a description"
end
attachments["appointment"] = { mime_type: "text/calendar", content: cal.to_ical }
mail to: to
end
end
- And I can successfully send the emails with a command like this:
bin/rails r "TestMailer.email_with_attachment.deliver_now"
Could you give us more details on how you're sending the emails? It looks that there is an issue with configuring the stream. We'd need a bit more context to be able to help you.
from postmark-rails.
@tomek-ac I believe I've solved the issue...
I was specifying the attachment as
mail.attachments['appointment.ics'] = {mime_type: 'text/calendar', content: @appointment.to_ical}
but had to instead use
attachments['appointment.ics'] = {mime_type: 'text/calendar', content: @appointment.to_ical}
The former syntax works via test/specs and other mailers, but it didn't work when sending via postmark. The latter syntax works now for me without specifying mail
at the start. The action mailer docs use the former syntax so there appears to be a bit of a compatibility issue: https://api.rubyonrails.org/classes/ActionMailer/Base.html#method-i-attachments
from postmark-rails.
Related Issues (20)
- Compatibility with latest postmark gem
- Gem version too constrained?
- Sending through different "Servers" HOT 1
- Release a new version of the gem to complete #76 HOT 1
- Emoji encoding issues in subject lines with Rails 3/4 apps HOT 1
- Add support for message stream archival HOT 2
- Message stream is not used when specified HOT 2
- Update default `http_ssl_version` - Similar issue to Postmark-gem HOT 5
- Postmark disabling TLSv1.0, What do I need to do? HOT 1
- Recipient email format `"Recipient Name" <[email protected]>` results in `Postmark::InvalidEmailAddressError` HOT 2
- Delivery Options HOT 1
- Rails 7 support HOT 2
- Cannot send metadata with #deliver_later HOT 1
- Postmark::InactiveRecipientError No Error Recipients HOT 1
- https release timeline HOT 2
- Calendar Attachments HOT 11
- Wrong documentation link HOT 1
- Does a soft bounce trigger a Postmark::InactiveRecipientError HOT 2
- Deprecation: Rails 7.1.1 - Using preview_path= option is deprecated and will be removed in Rails 7.2 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from postmark-rails.