| Server IP : 195.130.67.5 / Your IP : 216.73.216.231 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/icd/msc/ |
Upload File : |
<?php
require_once 'swiftmailer/lib/swift_required.php';
function sendSmtpMail($emailSubject, $emailBody, $recipient)
{
//$myemail = "tolisg <tolisg@teiser.gr>";
//$myemail2 = "erifili <erifili@teiser.gr>";
//$myemail3 = "Evi <evi@teiser.gr>";
//$notify = array('tolisg@teiser.gr' => "Apostolos Georgiadis");
$notify = array('tolisg@teiser.gr' => "Apostolos Georgiadis");
$notify["anpol@ihu.gr"] = "Anastasios Politis";
$notify["defstat@ihu.gr"] = "Dimitris Efstathiou";
$eml = (new Swift_Message($emailSubject))
->setFrom(array('msc.informatics.teicm.gr@gmail.com' => 'ICD MSc TEI of Central Macedonia'))
//->setReplyTo(array($ReplyEmail => $ReplayName))
->setTo($recipient)
->setBcc($notify)
->setBody($emailBody)
->addPart($emailBody, 'text/html');
// Optionally add any attachments
//->attach(Swift_Attachment::fromPath('my-document.pdf'));
//$gmail_smtp = "smtp.googlemail.com";
$gmail_smtp = "smtp.gmail.com";
//$gmail_smtp_ip = gethostbyname($gmail_smtp);
//$gmail_smtp_ip = "64.233.166.108";
//var_dump($gmail_smtp_ip);
//$transport = (new Swift_SmtpTransport($gmail_smtp, 465, 'ssl'))
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 587, 'tls')
->setAuthMode('login')
->setUsername("msc.informatics.teicm.gr@gmail.com")
->setPassword("icd2012msc")
->setTimeout(60);
//->setAuthMode("Login");
// Create the Mailer using your created Transport
$mailer = new Swift_Mailer($transport);
$logger = new \Swift_Plugins_Loggers_ArrayLogger();
$mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($logger));
$numSent = 0;
try {
$numSent = $mailer->send($eml);
} catch (Exception $ex) {
echo 'Caught exception: ', $ex->getMessage(), "\n";
}
//var_dump($transport);
//var_dump($mailer);
//var_dump($numSent);
var_dump($logger->dump());
$emailRes = ($numSent > 0);
return $emailRes;
}
$emailSubject = "test subject";
$emailBody = "test email body";
$recipient = array('tolis@agvm.org' => "Apostolos Georgiadis");
$emailRes = sendSmtpMail($emailSubject, $emailBody, $recipient);
var_dump($emailRes);
?>