Using SwiftMailer package in php and local mail server hMailServer. Php code:
<?php
require 'vendor/autoload.php';
$message=Swift_Message::newInstance();
$message->setFrom('webmaster@mail.com');
$message->setTo(array('testmail@mail.com'=>'Ilqar Rasulov'));
$message->setSubject('Delicious New Recipe');
//$message->setBody(<<<_TEXT_
//Dear James,
//You should try this: puree 1 pound of chicken with two pounds
//of asparagus in the blender, then drop small balls of the mixture
//into a deep fryer. Yummy!
//Love,
//Julia
//_TEXT_
//);
$message->addPart(<<<_TEXT_
<p>Dear James,</p>
<p>You should try this:</p>
<ul>
<li>puree 1 pound of chicken with two pounds
of asparagus in the blender</li>
<li>then drop small balls of the mixture into a deep fryer.</li>
</ul>
<p><em>Yummy!</em></p>
<p>Love,</p>
<p>Julia</p>
_TEXT_
, "text/html");
try{
$transport= Swift_SmtpTransport::newInstance('localhost',25);
$mailer= Swift_Mailer::newInstance($transport);
$mailer->send($message);
} catch (Exception $ex){
print $ex->getMessage();
}
I have configured my hMailServer and assigned passwords (admin and accounts password). So question is why swiftmailer needs only hostname and password to do its job, and doen't require authentification? Cuz I cann't remember that I stored username and password in any configuration files.