Skip to content
Advertisement

Email spoofing error: form is sending from submitted email, not server/domain

For example, if we enter any email in the form, we receive an email spoofing error when submitting the form. However, the form sends without error if we enter an email from the domain of the website.

How do we change the email to be sent from the domain instead of the email submitted from the form?

Thank you in advance for your time and skill. ????????

JavaScript

Advertisement

Answer

In $mail->setFrom($_POST['email'], $_POST['name']);, replace the $_POST values with a fixed email address which is from your domain. People often use a “noreply@…” type of address for this type of automated email. e.g.:

JavaScript

It needn’t be a “real” account with a mailbox necessarily, it just needs to be from the same domain as the server you’re sending it from, otherwise – rightly so – it gets identified as a spoofing / spam attempt.

If you need to know who it came from, put those values into the body of the email. And if you want to be able to hit “reply” and the email go back to the person who filled in the form, put their address in the reply-to header instead – both of which it looks like you’ve already done in this case.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement