Camufling sender address in an email in PHP

2

I can not camouflage the sender address @ anycoisa.com , I am obliged to use the one from my domain, but in my submission script that I lost I could camouflage, but I think this is hosting thing I use kinghost, the other time I did not use the kinghost and did not work to do so much, so much that I put in my code there, only when it enters the condition of the part of by the name that I want, if I by, does not accept, it seems that the hosting blocks the sending of the email, it should be, do you have any method ???

The code to send the html 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
}
    
asked by anonymous 16.10.2014 / 07:56

1 answer

2

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

Server that does not allow Relay

When sending emails, you may receive an error message that the email can not be sent due to a relay block ( relay ) by the SMTP server (< in> Simple Mail Transfer Protocol ).

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

Open Email Relay Server

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 email through it.

What translated:

  

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

Notes:

From server to server the settings change significantly, but the common thing is Relay not being allowed as it causes a lot of security and SPAM problem which lowers the reputation of the server itself.

Intermediate settings are also where email is sent without regard to FROM: but in the source of the message it is very explicit who sent it and usually follows with [email protected] although it appears in FROM: [email protected]     

16.10.2014 / 11:33