Camouflage sender address in a PHP email

Asked

Viewed 434 times

2

I can’t camouflage the sender’s address @anything with., I am obliged to use my domain name, but in my sending script that I lost I could camouflage, however I think this is something of the hosting I use kinghost, the other time I did not use the kinghost and I did not go to work to do, so much that I put in my code there, only that when you enter the condition of the part to put the name I want, if I put, does not accept, it seems that the hosting blocks the sending of the email, must be right, or has some method ???

The html upload code is:

function sendmail() {
    if(!isset($_POST[Submit])) die("Não foi recebido nenhum parâmetro");
    /* Medida preventiva para evitar que outros domínios sejam remetente da sua mensagem. */
    if (eregi('tempsite.ws$|locaweb.com.br$|hospedagemdesites.ws$|websiteseguro.com$', $_SERVER[HTTP_HOST])) {
            $emailsender=trim($_POST['emailremetente']);
    } else {
            $emailsender = "noreply@" . $_SERVER[HTTP_HOST];
    }

    /* Verifica qual é o sistema operacional do servidor para ajustar o cabeçalho de forma correta. Não alterar */
    if(PHP_OS == "Linux") $quebra_linha = "\n";
    elseif(PHP_OS == "WINNT") $quebra_linha = "\r\n";
    else die("Incompatibilidade com Sistema Operacional");

    // Passando os dados obtidos pelo formulário para as variáveis abaixo
    $nomeremetente     = $_POST['nomeremetente'];
    $emailremetente    = trim($_POST['emailremetente']);
    $assunto           = $_POST['assunto'];

    $array_emaildestinatario = array();
    $array_emaildestinatario = explode("\n",trim($_POST['emaildestinatario'])); // separa os emails pelas vírgulas em uma array
    foreach($array_emaildestinatario as $elemento) {
        //pra cada email envia
        /* Montando a mensagem a ser enviada no corpo do e-mail. */
        $mensagemHTML = html();


        /* Montando o cabeçalho da mensagem */
        $headers = "MIME-Version: 1.1".$quebra_linha;
        $headers .= "Content-type: text/html; charset=iso-8859-1".$quebra_linha;
        // Perceba que a linha acima contém "text/html", sem essa linha, a mensagem não chegará formatada.
        $headers .= "From: ".$emailsender.$quebra_linha;
        $headers .= "Return-Path: " . $emailsender . $quebra_linha;

        $headers .= "Reply-To: ".$emailremetente.$quebra_linha;
        // Note que o e-mail do remetente será usado no campo Reply-To (Responder Para)

        /* Enviando a mensagem */
        mail($elemento, $assunto, $mensagemHTML, $headers, "-r". $emailsender);
    }
    /* Mostrando na tela as informações enviadas por e-mail */
    ?>
        <div style="color:white;border:1px solid black;padding:15px;background-color:rgba(150,50,50,0.8);font-family:Arial;margin-bottom:5px;font-size:14px;">
            Enviando <?php echo count($array_emaildestinatario); ?> e-mails, aguarde um instante...
        </div>
        <div style="color:white;border:1px solid black;padding:15px;background-color:rgba(150,50,50,0.8);font-family:Arial;margin-bottom:5px;font-size:14px;">
            De:<?php echo $emailsender; ?>
        </div>
        <div style="color:white;border:1px solid black;padding-left:15px;padding-top:5px;padding-bottom:5px;background-color:rgba(150,50,50,0.3);font-family:Arial;margin-bottom:5px;font-size:14px;">
        <?php 
        foreach($array_emaildestinatario as $elemento) {
            echo "<p>$elemento</p>";
        }
        ?>
        </div>
<?php
}

1 answer

2


You should talk to the Technical support from Kinghost to get an exact answer to your question, but from what I see in FAQ for email configuration, sending emails requires authentication which is indicative of the server not being Open Email Relay.

Server that does not allow Relay

When sending emails, you may receive an error message to realize that the email cannot be sent due to a relay block (re-lay) by the SMTP server (Simple Mail Transfer Protocol).

The exact error message may vary depending on the server but essentially tells me that the server does not allow re-lay, authentication is required to send the email and/or be using an existing account on the server for this purpose.

Server Open Email Relay

What you are trying to do requires a server configured as Open Email Relay:

An open mail Relay is an SMTP server configured in such a way that it Allows anyone on the Internet to send e-mail through it.

That translated:

An open mail Relay is an SMTP server configured in such a way that allows anyone on the Internet to send emails through it.


Notes:

From server to server the settings change significantly, but the common is the Relay not be allowed as it carries too much security problem and SPAM which lowers the reputation of the server itself.

Intermediate settings are also where sending emails is done without consideration to FROM: but the source of the message is very explicit who sent and usually follows with [email protected] despite appearing in the FROM: [email protected].

Browser other questions tagged

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