there are two options for testing your SMTP settings:
-
enter your settings in admin and send yourself a “forgot password” email. You can enable SMTP debugging in your config.inc.php but it will affect everybody in your shop, so if your shop is already live you should go with seconds option.
-
create new file in source directroy and give it a random name, so nobody can guess it, then paste this code into your file:
<?php
require_once "bootstrap.php";
$oConfig = \OxidEsales\Eshop\Core\Registry::getConfig();
$recipient = $oConfig->getRequestParameter("recipient") ;
$smtpHost = $oConfig->getRequestParameter("host");
$smtpPort = $oConfig->getRequestParameter("port");
$smtpUser = $oConfig->getRequestParameter("user");
$smtpPass = $oConfig->getRequestParameter("pass");
print '<html>
<body>
<form action="">
<table width="">
<tr>
<td><input type="text" name="host" placeholder="host" value="'.$smtpHost.'" /></td>
<td><input type="text" name="port" placeholder="port" value="'.$smtpPort.'" /></td>
<td><input type="text" name="user" placeholder="user" value="'.$smtpUser.'" /></td>
<td><input type="text" name="pass" placeholder="pass" value="'.$smtpPass.'" /></td>
<td><input type="text" name="recipient" placeholder="recipient" value="'.$recipient.'" /></td>
<td><button type="submit">📧</button></td>
</tr>
</table>
</form>
</body>
</html>';
if($smtpHost && $smtpPort && $smtpUser && $smtpPass && $recipient)
{
$oEmail = oxNew(\OxidEsales\Eshop\Core\Email::class);
$oEmail->IsSMTP();
$oEmail->SMTPDebug = 3;
$oEmail->SMTPAuth = true;
$oEmail->Host = $smtpHost;
$oEmail->Port = $smtpPort;
$oEmail->SMTPSecure = "tls";
$oEmail->Username = $smtpUser;
$oEmail->Password = $smtpPass;
$oEmail->setFrom($smtpUser);
$oEmail->setRecipient($recipient);
$oEmail->setSubject($smtpUser." Test Email from ".gethostname());
$oEmail->setBody("<h1>".date("Y-m-d H:i:s")."</h1>");
$oEmail->setAltBody(date("Y-m-d H:i:s"));
var_dump($oEmail->send());
}
now you can manually enter your smtp data and test it before changing OXID settings.