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

Translate from mail() parameters style library to PHPMailer library #2953

Closed
Flow75 opened this issue Sep 11, 2023 · 1 comment
Closed

Translate from mail() parameters style library to PHPMailer library #2953

Flow75 opened this issue Sep 11, 2023 · 1 comment

Comments

@Flow75
Copy link

Flow75 commented Sep 11, 2023

Hello,

I've implemented since day 1 the mail function on my server.

I would like to transfert the mail part to PHPMailer (it seems much faster than the sendmail protocol).

So I've all my mail() calls implemented with the body, adress_to, Headers. And when I send files attached, they are already in the body with the boundary.

Is there a way not to rewrite all php scripts calling mail() and replace the call by other thing ?

Thank you.
F.

@Synchro
Copy link
Member

Synchro commented Sep 11, 2023

There isn't an automated way of doing this because there are infinite ways that you can prepare content for what's sent using mail(). Translating your setup should not be too difficult though. Map all your recipients to the addAddress(), addCC(), and addBCC() methods, set headers using addCustomHeader() (but check whether you need to first - PHPMailer sets all the important ones for you), set your subject by setting the Subject property, and make use of addAttachment to add your attachments. Boundaries are all handled for you, so you don't need to worry about them.

You should be able to bundle all this into a function that accepts most of the inputs you're currently generating yourself, and then replce your mail() calls with calls to this wrapper function instead.

I would not expect simply switching to PHPMailer directly would give you any performance advantage, but if you call isSMTP(), it should be faster than using mail() when sending to localhost.

@Synchro Synchro closed this as completed Nov 23, 2023
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

2 participants