If you want to send via Gmail, the mail() function is unlikely to work. In any case, it has some pretty severe security problems, so the best advice is to avoid it entirely.
Use a good quality PHP library instead. There are many, and the main ones are PHPMailer and SwiftMailer.
It’s been working just fine for me for the last five months on 000webhost, so try again! I got 000webhost, PHPMailer and Gmail working together just a couple of days ago. If you’re having trouble with it, show us the smallest possible PHP script that illustrates your problem.
i did try with various code PHPMalier and nothing. Here down.
<?php
// Inclui o arquivo class.phpmailer.php localizado na pasta class
require_once("class/class.phpmailer.php");
// Inicia a classe PHPMailer
$mail = new PHPMailer(true);
// Define os dados do servidor e tipo de conexão
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
$mail->IsSMTP(); // Define que a mensagem será SMTP
try {
$mail->Host = 'smtp.seudominio.com.br'; // Endereço do servidor SMTP (Autenticação, utilize o host smtp.seudomínio.com.br)
$mail->SMTPAuth = true; // Usar autenticação SMTP (obrigatório para smtp.seudomínio.com.br)
$mail->Port = 587; // Usar 587 porta SMTP
$mail->Username = 'usuário de smtp'; // Usuário do servidor SMTP (endereço de email)
$mail->Password = 'senha de smtp'; // Senha do servidor SMTP (senha do email usado)
//Define o remetente
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
$mail->SetFrom('seu@e-mail.com.br', 'Nome'); //Seu e-mail
$mail->AddReplyTo('seu@e-mail.com.br', 'Nome'); //Seu e-mail
$mail->Subject = 'Assunto';//Assunto do e-mail
//Define os destinatário(s)
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
$mail->AddAddress('e-mail@destino.com.br', 'Teste Locaweb');
//Campos abaixo são opcionais
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//$mail->AddCC('destinarario@dominio.com.br', 'Destinatario'); // Copia
//$mail->AddBCC('destinatario_oculto@dominio.com.br', 'Destinatario2`'); // Cópia Oculta
//$mail->AddAttachment('images/phpmailer.gif'); // Adicionar um anexo
//Define o corpo do email
$mail->MsgHTML('corpo do email');
////Caso queira colocar o conteudo de um arquivo utilize o método abaixo ao invés da mensagem no corpo do e-mail.
//$mail->MsgHTML(file_get_contents('arquivo.html'));
$mail->Send();
echo "Mensagem enviada com sucesso</p>\n";
//caso apresente algum erro é apresentado abaixo com essa exceção.
}catch (phpmailerException $e) {
echo $e->errorMessage(); //Mensagem de erro costumizada do PHPMailer
}
?>
Looks like you’re missing the authentication scheme:
$mail->SMTPSecure = 'tls'; // Matches your 587 port
If that does not help, look at your error info and turn on SMTP logging:
// Before the send
$smtpLogs = [];
$mail->SMTPDebug = 2;
$mail->Debugoutput = 'logHandler';
// Your send goes here
$mail->Send();
// After the send
print_r($mail->ErrorInfo);
printLogs($smtpLogs);
function logHandler($log, $level)
{
global $smtpLogs;
$smtpLogs[] = trim($log);
}
function printLogs(array $logs)
{
echo implode("\n", $logs) . "\n";
}
If you are still stuck, please provide your SMTP logs - I cannot help without those.
As pointed out in my earlier post, a mailing server is down and developers will fix it as soon as possible. PHP mail() function will not work until issue is fixed unfortunately
Also, SMTP is not supported on 000webhost. From our websites you can send e-mails using only mail() function.
I was assuming that @shimatani is trying their own SMTP server with PHPMailer. I was guessing that smtp.seudominio.com.br is not an alias for a 000webhost server