Skip to content
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

Allow preSend() without recipients #2948

Closed
mschering opened this issue Aug 25, 2023 · 6 comments
Closed

Allow preSend() without recipients #2948

mschering opened this issue Aug 25, 2023 · 6 comments

Comments

@mschering
Copy link

Hi,

I have a small feature request. In my application I store mail templates in MIME format. For that purpose I don't want any recipients inside.

At the moment it's not possible to create this because of the validation at line 1568. Perhaps you could set a property "allowNoRecipients" or something like that.

Best regards,
Merijn

@Synchro
Copy link
Member

Synchro commented Aug 25, 2023

I don't know that that would be effective because PHPMailer wants to build the MIME structure for you, and it's generally tricky to get it to send an already-formatted message. Have you worked around that already, or are you only using PHPMailer for constructing messages and sending them some other way?

Alternatively I'd suggest storing the original raw message body and passing that into PHPMailer when you're sending, letting it build the structure as it sends rather than trying to shortcut that.

@mschering
Copy link
Author

mschering commented Aug 25, 2023

I am using it for both sending and those templates. So when I want to save the template I call preSend() and then get the MIME with getSentMIMEMessage(). Works fine but only if a recipient is set.

@Synchro
Copy link
Member

Synchro commented Aug 25, 2023

Yes, I understand that, I'm saying that it would work better if you didn't do it that way. Why do you need to save the fully formatted message when it's impractical to use that as a template (because encodings will really get in the way), and it's much more difficult to send it later (because PHPMailer doesn't make it easy to send an existing RFC822 message)?

@mschering
Copy link
Author

You're right. I do it that way for legacy reasons. The MIME is decoded when loading the template editor which works fine but I understand it can be done more efficiently. We need to refactor that later but for now I can't do that.

@XL-2000
Copy link

XL-2000 commented Aug 26, 2023

So, if it is not the intended use of the PHPMailer software and if it is temporary, and you are refactoring this later on; why not temporarily make those changes in your local version of PHPMailer until you are using it the proper way? In essence, make your own fork of the code

@mschering
Copy link
Author

Yes if it’s not an option you’d like to support I’ll go that route.

thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants