Forwarding mail in PHP

I am developing a dynamic mail forwarding component for a website.

The concept is that - the user will send an email with arbitrary content to a special email address on the server - based on the contents of the "to" and "subject" strings, the system will send an email to a group of (external) email addresses that are retrieved from the mysql database

I am running a shared web host (Bluehost), so I don’t think I have any advanced access to the mail infrastructure to do this for me (for example, there are no .forward files). The list of destination email addresses is dynamic, so I cannot use cPanel to configure static forwarding.

I have incoming mail arriving in a PHP script, but the processing looks complicated, especially for the MIME parts - multipart, attachments, etc. I looked at PEAR Mail / MIME stuff, but it seems to completely decode and transcode msg ...

Any tips?

+4
source share
1 answer

I am using phpMailer to send email with PHP.

I implemented exactly the same concept in mod_perl a few years ago. Keep in mind that most of your outgoing mail is likely to be blocked if you send a significant amount. And if your system can be hacked (and it sounds at least believable), spammers can find it and use your system, which will lead to blocking all your outgoing email.

Sending e-mail is more complicated than it should be (considering technology only) thanks to spam and spam filters. These days, it's often easier for me to write code that uses a third-party service to actually send emails by submitting addresses via the API. I was lucky recently with MailChimp and Contactology APIs.

EDIT: as for an incoming letter: if you were not in a situation with shared hosting, it would not be so difficult - just grab it, split the headers and pull it back to the new address. I have to agree with Conrad, I think at this point - the shared PHP script host seems like a pretty suboptimal environment to try and solve this problem. If you cannot use system () to directly pass the mail infrastructure, I think you need to completely parse the incoming email and collect it.

0
source

Source: https://habr.com/ru/post/1394724/


All Articles