E
E
Eugene_Koi2017-07-25 16:26:22
PHP
Eugene_Koi, 2017-07-25 16:26:22

How to send form data to multiple emails?

I use this library to send data from feedback forms to email https://github.com/agragregra/uniMail
There was a need to send data to several emails at once. Please tell me how this can be done

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Y
Yuri Esin, 2017-07-25
@Eugene_Koi

As an option, form an array of postal addresses and repeat the call to the method of sending a letter in a cycle, while changing the addressee. A generic way that even works for mail(). I am not familiar with uniMail, perhaps it already provides for automation of sending to several recipients, then it will be easier. If there is no such thing - again, the method with the cycle will do here.
UPD: I looked at this uniMail ... everything is sad there. You can write a better library in an hour. The algorithm is approximately the following:
Server:
1. Do the storage of addressees (you can configure, you can use a database, whichever suits you best);
2. Validate query input parameters, filter variables, escape special characters;
3. Form an array of recipients from the stored data;
4. Write the function of forming a letter, it will also send it;
5. Loop through the array of destinations, pass arguments to the function, and call it on each iteration.
Client:
Here you just need to collect the data and send it to the server processing script, which I described above. How you organize the sending (ajax, direct post, etc.) - this will work, the main thing, as Alexander noted below, do not store important information in hidden fields, and in general, never store anything like that on the client, starting with DOM and ending with cookies and GET parameters in the address bar.

I
Ilya, 2017-07-25
@Rimush

Doesn't it work with a comma?

A
Alexander Novikov, 2017-07-25
@AlexndrNovikov

As Ilya correctly answered , the comma will help, since the mandrel in the code is carried out by the banal mail().
But in general, the library is just terrible, it would be better to refuse this one.
The recipients field comes from a hidden form field. This is a direct vulnerability, you can replace it with an arbitrary one even in the browser - and you can send anything and anyone through your site.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question