One possible solution to remove this would be to use PHPMailer to upload.
First download via composer into your project folder (your using composer):
composer require phpmailer/phpmailer
Or download the latest Release at: link
If you downloaded extract the PHPMailer-5.2.14
folder in the folder that your script is, the folder structure should look something like:
./projeto
|---- enviaremail.php
|---- PHPMailer-5.2.14/
|---- PHPMailerAutoload.php
|---- ...
enviaremail.php :
<?php
require 'PHPMailer-5.2.14/PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Pra depurar o código remova o // do começo
$mail->isSMTP(); // Define como SMTP
$mail->Host = 'smtp.exemplo.com'; // Endereço do SMTP
$mail->Port = 25; // Porta do SMTP
$mail->SMTPAuth = true; // Autenticação no SMTP
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = 'senha'; // SMTP password
//$mail->setFrom('[email protected]', 'Mailer'); //comentei esta linha pois o Gmail irá detectar se tentar alterar o "from", mas pode tentar
//Adiciona destinatários:
$mail->addAddress('[email protected]', 'Joe User'); // Adiciona destinatário
$mail->addAddress('[email protected]'); // Destinatário sem nome
$mail->addReplyTo('[email protected]', 'Information');
//Manda como cópia
$mail->addCC('[email protected]');
//Manda como cópia oculta
$mail->addBCC('[email protected]');
//Anexos se precisar
$mail->addAttachment('/var/tmp/file.tar.gz');
$mail->addAttachment('/tmp/image.jpg', 'new.jpg');
//Habilita HTML
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Assunto';
$mail->Body = 'Mensagem <b>teste</b>';
$mail->AltBody = 'Mensagem em texto, alternativa ao HTML';
if(!$mail->send()) {
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Mensagem enviada';
}
If you're going to use Gmail as a sender, you'll have to unlock it in Gmail settings, so the settings for using your Gmail account to send emails are:
//Set the hostname of the mail server
$mail->Host = 'smtp.gmail.com';
// use
// $mail->Host = gethostbyname('smtp.gmail.com');
// Se a rede não suportar SMTP sobre IPv6
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = "[email protected]";
$mail->Password = "yourpassword";
For other issues see: