I can not use sendmail through php. how do I do?
// multiple recipients
$to = 'wesley.sto.rodrigues@gmail.com' . ', '; // note the comma
//$to .= 'wez@example.com';
// subject
$subject = 'Birthday Reminders for August';
// message
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= '';
//$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
//$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
//$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
Cibele
February 27, 2018, 7:17pm
#2
Hi there,
i have a send email in my site and it works. u can try the code i use:
<?php
$name = $_POST ['name'];
$email = $_POST ['email'];
?>
<?php
$to = "your email";
$subject = "...";
$message = "...";
$header = "MIME-Version: 1.0\n";
$header .= "Content-type: text/html; charset=iso-8859-1\n";
$header .= "From: $email\n";
mail($to, $subject, $message, $header);
echo "E-mail sent.";
?>
i took from a forum some time ago, hope it help u out
[update] it didnt take the right spaces in the codeâŠidk why⊠so try separate it by lines.
2 Likes
nothing. not function sendmail free 000webhost
1 Like
teodor
February 28, 2018, 12:25pm
#4
Hi @shimatani !
It appears that one of our mailing servers is temporarily down. Please try again later.
We are sorry for inconvenience
1 Like
teodor
Split this topic
February 28, 2018, 8:43pm
#5
2 posts were merged into an existing topic: Send Email Help
I can not use sendmail through php. how do I do?
What errors do you encounter?
not had errors, but not send email to gmail.com what i config here
$emails = "email local";
$to = "send-email@gmail.com";
$subject = "ALERTS";
$message = "TEST";
$header = "MIME-Version: 1.0\n";
$header .= "Content-type: text/html; charset=iso-8859-1\n";
$header .= "From: $emails\n";
mail($to, $subject, $message, $header);
halfer
March 1, 2018, 12:07am
#9
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.
PHPMailer not function too. i did try and nothing
halfer
March 1, 2018, 12:28am
#11
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.
1 Like
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
}
?>
sorry the â//â coments in portuguese brazilian. because im brasilian, all right? thanks.
halfer
March 1, 2018, 12:41am
#14
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.
teodor
March 1, 2018, 12:45am
#15
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.
halfer
March 1, 2018, 12:55am
#16
Works just fine for me, with a range of external mail providers. Do you mean that 000webhost donât provide their own SMTP mail servers?
halfer
March 1, 2018, 12:57am
#18
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
@halfer i have the gmail mail SMTP. will not function?
halfer
March 1, 2018, 1:04am
#20
You have to make a settings change in Gmail:
Go to the cog icon in the top-right
Click on the Settings menu entry
Click on the Accounts and Import tab
Get to the Google Accounts section
Find the Apps With Account Access section
Turn on âAllow less secure appsâ
If thatâs not it, then I wonât help further until I see your SMTP logs.
1 Like