I
I
Isherath2019-01-27 18:36:01
Email
Isherath, 2019-01-27 18:36:01

How to change sender email dynamically?

On the site, one user publishes content, another user can send a message to him through the site and then communicate only by mail. That is, the site as a link between two users.
But! The problem is that sending via yii2 swiftmail doesn't work if I do like this

...
->setFrom('[email protected]');
...

That is, if I substitute the mail of a user who wants to send a message through my site instead of the site's mail.
And if I put the site's mail there, which appears in the swiftmailer config, then the mail is sent without problems, but in this situation, the user will not be able to directly continue to communicate with another user on his mails. And there is no point in sending mail.
In short, I cannot specify anything else in setFrom other than the mail that is specified in the configuration.
Tell me how to implement this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2019-01-28
@Isherath

the sender should be your business email, and in the body of the letter you insert a link button with mailto that will generate a letter to the desired user.

A
Arthur K., 2019-01-27
@amark

Spammers dreamed about your decision about 5 years ago.
It turns out that your script can send a message on behalf of any user? without the knowledge of the user?

- But this user entered his mail!
you say.
And who said that he also sent the second letter? Where are the guarantees?
How is the receiving mail server supposed to make sure that it's the user who clicked the "submit" button on your site, and not an attacker script doing a malicious mailing?
Technically speaking, your script should log in to your client's smtp server with his username/password and send mail via native smtp. Or, the client's mail domain records must state that your sending server is a trusted source.
In other cases, you are a malicious villain who pretends to be someone else.
ps Try changing the "ReplyTo" header. Maybe it will be painless.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question