-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net.smtp: public mail attachment #23477
Conversation
Connected to Huly®: V_0.6-21907 |
Rather than making these fields public, I think I would rather have seen a method added - parameters could be the attachment itself, and a optional type (if you wanted to send it as something other than plain text/binary - which would be figured out in the method if no specific type was given). Otherwise... what the heck does A method could set it correctly, without everyone having to know. |
What would the API look like, if you want to send say 2 attachments? |
The |
One or more calls to |
Can you please show the example from the issue, but written as you expect it to be clearer? |
The relevant part is this: send_cfg := smtp.Mail{
from: '${nicename}<${sender}>'
to: receivers
subject: subject
body_type: smtp.BodyType.html
body: body
attachments: [
smtp.Attachment {
filename: 'readme.txt'
bytes: '...Some file content...'.bytes()
}
]
} |
Instead of what is has now, I'd prefer something like mut send_cfg := smtp.Mail{
from: '${nicename}<${sender}>'
to: receivers
subject: subject
body_type: smtp.BodyType.html
body: body
}
send_cfg.attachment(name: 'readme.txt', contents: '...Some file content...'.bytes()) or perhaps send_cfg.attachment(name: 'readme.txt', contents: '...Some file content...'.bytes(), type: 'application/json') The Why would I want to do this? Suppose you wanted to send that same |
The cid does not determine the type. It adds an id, that can be referenced in the body (if it contains say an html message with The type of the attachment is currently hardcoded in the Attachment.to_string/1 method, and is |
I think that the current PR is fine, and a public method on smtp.Mail for adding attachments can be added, but is out of scope of this PR. |
@7underlines thank you. Good work. |
i.e. you want something that is not supported currently, and will not affect the need for those fields to be public. |
... except they wouldn't need to be public if the new method were added. Oh, well. |
They need to, to allow the more natural initialization, described in the issue. |
Note that previously that worked (in January last year), but V became stricter in time, and now checks the |
It could be argued, that we should have tests for those, that exercise that ability, so that it will not regress in the future, and we can also add the ability to customize the attachment type too (with a suitable default of |
This should fix adding mail attachments if not inside v module.
See also #20640