PHP code example of toropyga / fmail
1. Go to this page and download the library: Download toropyga/fmail library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
toropyga / fmail example snippets
$ml = new Toropyga\FMail();
$ml->setMailUse(false);
$ml->setServer('your_mailserver.com'); // you can specify an IP address or a domain name
$ml->setPort(2525); // specifies the port number
$ml->setTimeout(30); // specify the time in seconds
$ml->setAuth('PLAIN'); // specify the authorization method: LOGIN or PLAIN
$ml->setLogin('login'); // specify the user's login
$ml->setPassword('password'); // specify the user's password
$ml->setMaxRecipient(2); // number of simultaneous message recipients
$ml->setCharset('WIN'); // specify the encoding code
// (WIN=>windows-1251, UTF=>utf-8, ISO=>iso-8859-1, KOI=>koi8-r)
$ml->setTo('[email protected] ');
$ml->setTo('[email protected] ', 'Ivan Ivanov');
$ml->setTo('[email protected] ', $ml->getWin2Utf('Vasya Pupkin'));
$ml->setTo(array(array('mail'=>'[email protected] ', 'username'=>'Ivan Ivanov')));
$ml->clearTo();
$ml->setBcc('[email protected] ');
$ml->setBcc('[email protected] ', 'Ivan Ivanov');
$ml->setBcc('[email protected] ', $ml->getUtf2Win('Vasya Pupkin'));
$ml->setBcc(array(array('mail'=>'[email protected] ', 'username'=>'Ivan Ivanov')));
$ml->clearBcc();
$ml->setFrom('[email protected] ');
$ml->setFrom('[email protected] ', 'Sender Name');
$ml->setSubject('Message subject');
$ml->setMessage("Message text here!");
$ml->setHTMLMessage("Message text here");
$ml->setHTMLMessage("<html><body>Here<br>is the<b>message text!!!</b></body></html>");
$ml->setMessageFromHTML("file.html"); // specify the path to the HTML file
$ml->setHTMLfile("file.html"); // specify the path to the HTML file
$ml->setFile("file1.txt"); // specify the path to the file
$ml->setFile("file2.gif");
$ml->setFile("file3.zip");
$ml->clearFiles();
$ml->send();
$ml = new Toropyga/FMail();
$ml->setServer('your_mailserver.com'); // you can specify an IP address or a domain name
$ml->setImapPort(993); // specifies the port number
$ml->setImapType('pop3');
$ml->setImapFlags('/ssl/debug/user=Administrator', true);
$ml->setLogin('login'); // specify the user's login
$ml->setPassword('password'); // specify the user's password
$folders = $ml->getImapFolders();
$ml->setImapFolder('INBOX/Work');
$ml->read_folder('INBOX', 124, 10);
$mails = $ml->receive('UNSEEN'); // see the function description for the list of parameters
$ml->read_mail(124);
$ml->read_mail_UID(24);
$ml->getCheck('[email protected] ');
$text = $ml->getWin2Utf($text); // pass the text to be converted
$text = $ml->getUtf2Win($text); // pass the text to be converted
$ml->setDebug(true);
$logs = $ml->getLogs(3); // when debug functions are enabled, displays the logs on screen
$text = $ml->getSubjectDecode($text);
$ml = new Toropyga\FMail();
$ml->setMailUse(false);
$ml->setServer('your_mail_server.com');
$ml->setAuth('LOGIN');
$ml->setLogin('login');
$ml->setPassword('password');
$ml->setMaxRecipient(2);
$ml->setCharset('UTF');
$ml->setTo('[email protected] ');
$ml->setTo('[email protected] ', 'Ivan Ivanov');
$ml->setBcc('[email protected] ');
$ml->setFrom('[email protected] ', $ml->getWin2Utf('Sender Name'));
$ml->setSubject('Message subject');
$ml->setHTMLMessage("Message text here");
$ml->setFile("file1.txt");
$ml->setFile("file2.gif");
$ml->setFile("file3.zip");
if (!$ml->send()) {
$ml->setDebug(true);
$ml->getLogs();
}
else echo "Mail sending - OK";