To change the FROM parameter of sending email so that the sending server does not appear

Asked

Viewed 477 times

0

I’ve been using this tutorial as base, but when sending the message by email (using PHP) appears as sending server io.wv.pt.

Example 1:

Exemplo 1

Example 2:

Exemplo 2

PHP code:

<?php
    if (isset($_POST['postsubmit'])) {
        mail($_POST['to'], $_POST['subject'] , $_POST['mensagem'], 'From: '    .$_POST['email']);
        echo 'sent';
        echo $_POST['mensagem'];
    }
?>

How do I fix this?

  • I already solved. But left no link to the question.

  • meant on the link indicated as duplicate: http://answall.com/questions/118364/gmail-displayinghost-de-origem-no-destinat%C3%a1rio-quando-uso-mail-do-php

  • You’re right. You can delete this one. But I’m going to ask another question because by solving my problems I think I can help other people who want to send emails.

  • It is better not to eliminate, so whoever looks for one or the other. This is precisely the idea of marking as duplicate. More of a way to find the information. Thus, formulated in two different ways, the solutions have more chance to be found.

  • Okay. Thanks just the same :)

1 answer

2


In the fourth function parameter mail(), define the header.

$to      = $_POST['to'];
$subject = $_POST['subject'];
$message = $_POST['mensagem'];
$headers = 'From: NOME DE QUEM ENVIA <'.$_POST['email'].'>'.PHP_EOL.
'X-Mailer: PHP/'.phpversion();

mail($to, $subject, $message, $headers);

However, it depends on the SMTP server (who actually sends the email).

The SMTP server may not allow you to customize the sender name.

  • Yeah, that’s what I need.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.