authenticated smtp
Posted: Thu Aug 05, 2021 3:32 pm
Hello people.
I put two new sites up, built "as usual", but the contact forms don't send messages to the customer's mailboxes.
Verified and correct emails and passwords.
The host works with authenticated smtp and then in the Advanced settings of form I changed it to SMTP mail engine and other settings according to the host, but the forms still don't send the msgs.
Some time ago I used DBTS to solve problems like this, but it is no longer among the available extensions.
Any tips?
This is the code template that the hosting company gave me:
1st step
Download PHP Mailer by clicking here and select the “PHPMailer_5.2.4.zip” option;
2nd step
Create a file with the extension “.php” (example: formrio.php) with the example code below and extract the file "PHPMailer_5.2.4.zip" in the same directory:
<?php
/* only triggers the form submission if there is $_POST['sendFormulario']*/
if (isset($_POST['sendForm'])){
/*** START - DATA TO BE CHANGED ACCORDING TO YOUR E-MAIL SETTINGS ***/
$enviaFormularioParaName = 'Name of the recipient who will receive the form';
$enviaFormularioParaEmail = 'email-do-recipient@domain';
$MailboxServerName = 'WebSite | Form';
$CaixaPostalServidorEmail = 'user@yourdomain.com.br';
$MailboxServerPassword = 'password';
/*** END - DATA TO BE CHANGED ACCORDING TO YOUR E-MAIL SETTINGS ***/
/* below are the main variables, which must be included in your form*/
$senderName = $_POST['senderName'];
$senderEmail = $_POST['senderEmail'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$mensagemConcatenada = 'Form generated via website'.'<br/>';
$Concatenated message .= '------------------------------<br/><br/>';
$Concatenated message .= 'Name: '.$senderName.'<br/>';
$MensagemConcatenada .= 'Email: '.$senderEmail.'<br/>';
$messagemConcatenada .= 'Subject: '.$subject.'<br/>';
$Concatenated message .= '------------------------------<br/><br/>';
$messagemConcatenada .= 'Message: "'.$message.'"<br/>';
/*********************************** FROM HERE DO NOT CHANGE ********* ***************************/
require ('PHPMailer_5.2.4/class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Charset = 'utf8_decode()';
$mail->Host = 'smtp.'.substr(strstr($MailMailServerEmail, '@'), 1);
$mail->Port = '587';
$mail->Username = $MailboxServerEmail;
$mail->Password = $MailboxServerPassword;
$mail->From = $MailMailServerEmail;
$mail->FromName = utf8_decode($MailboxServerName);
$mail->IsHTML(true);
$mail->Subject = utf8_decode($subject);
$mail->Body = utf8_decode($Concatenatedmessage);
$mail->AddAddress($sendFormToEmail,utf8_decode($sendFormToName));
if(!$mail->Send()){
$mensagemRetorno = 'Error sending form: '. print($mail->ErrorInfo);
}else{
$messagemRetorno = 'Form sent successfully!';
}
}
?>
<html lang="en-US">
<head>
<meta charset="utf-8">
<title>Authenticated Sample Form</title>
</head>
<body>
<?php
if(isset($Return message)){
echo $messageReturn;
}
?>
<form method="POST" action="" style="width:300px;">
<input type="text" name="senderName" placeholder="Full name" style="float:left;margin:10px;">
<input type="text" name="SenderEmail" placeholder="Email" style="float:left;margin:10px;">
<input type="text" name="Subject" placeholder="Subject" style="float:left;margin:10px;">
<textarea name="message" placeholder="Message" style="float:left;margin:10px;height:100px;width:200px;"></textarea>
<input type="submit" value="submit" name="submitForm" style="float:left;margin:10px;">
</form>
</body>
</html>
Note: The code used above is just an example.
I put two new sites up, built "as usual", but the contact forms don't send messages to the customer's mailboxes.
Verified and correct emails and passwords.
The host works with authenticated smtp and then in the Advanced settings of form I changed it to SMTP mail engine and other settings according to the host, but the forms still don't send the msgs.
Some time ago I used DBTS to solve problems like this, but it is no longer among the available extensions.
Any tips?
This is the code template that the hosting company gave me:
1st step
Download PHP Mailer by clicking here and select the “PHPMailer_5.2.4.zip” option;
2nd step
Create a file with the extension “.php” (example: formrio.php) with the example code below and extract the file "PHPMailer_5.2.4.zip" in the same directory:
<?php
/* only triggers the form submission if there is $_POST['sendFormulario']*/
if (isset($_POST['sendForm'])){
/*** START - DATA TO BE CHANGED ACCORDING TO YOUR E-MAIL SETTINGS ***/
$enviaFormularioParaName = 'Name of the recipient who will receive the form';
$enviaFormularioParaEmail = 'email-do-recipient@domain';
$MailboxServerName = 'WebSite | Form';
$CaixaPostalServidorEmail = 'user@yourdomain.com.br';
$MailboxServerPassword = 'password';
/*** END - DATA TO BE CHANGED ACCORDING TO YOUR E-MAIL SETTINGS ***/
/* below are the main variables, which must be included in your form*/
$senderName = $_POST['senderName'];
$senderEmail = $_POST['senderEmail'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$mensagemConcatenada = 'Form generated via website'.'<br/>';
$Concatenated message .= '------------------------------<br/><br/>';
$Concatenated message .= 'Name: '.$senderName.'<br/>';
$MensagemConcatenada .= 'Email: '.$senderEmail.'<br/>';
$messagemConcatenada .= 'Subject: '.$subject.'<br/>';
$Concatenated message .= '------------------------------<br/><br/>';
$messagemConcatenada .= 'Message: "'.$message.'"<br/>';
/*********************************** FROM HERE DO NOT CHANGE ********* ***************************/
require ('PHPMailer_5.2.4/class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Charset = 'utf8_decode()';
$mail->Host = 'smtp.'.substr(strstr($MailMailServerEmail, '@'), 1);
$mail->Port = '587';
$mail->Username = $MailboxServerEmail;
$mail->Password = $MailboxServerPassword;
$mail->From = $MailMailServerEmail;
$mail->FromName = utf8_decode($MailboxServerName);
$mail->IsHTML(true);
$mail->Subject = utf8_decode($subject);
$mail->Body = utf8_decode($Concatenatedmessage);
$mail->AddAddress($sendFormToEmail,utf8_decode($sendFormToName));
if(!$mail->Send()){
$mensagemRetorno = 'Error sending form: '. print($mail->ErrorInfo);
}else{
$messagemRetorno = 'Form sent successfully!';
}
}
?>
<html lang="en-US">
<head>
<meta charset="utf-8">
<title>Authenticated Sample Form</title>
</head>
<body>
<?php
if(isset($Return message)){
echo $messageReturn;
}
?>
<form method="POST" action="" style="width:300px;">
<input type="text" name="senderName" placeholder="Full name" style="float:left;margin:10px;">
<input type="text" name="SenderEmail" placeholder="Email" style="float:left;margin:10px;">
<input type="text" name="Subject" placeholder="Subject" style="float:left;margin:10px;">
<textarea name="message" placeholder="Message" style="float:left;margin:10px;height:100px;width:200px;"></textarea>
<input type="submit" value="submit" name="submitForm" style="float:left;margin:10px;">
</form>
</body>
</html>
Note: The code used above is just an example.