PHP code example of uralmas / external-mailer

1. Go to this page and download the library: Download uralmas/external-mailer 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/ */

    

uralmas / external-mailer example snippets





	//First argument - the address on which the script is located sending mail
	//Sencond - root of filepath
    $sender = new UralMas\ExternalMailer\Client('http://server.ru/', 'http://client.ru/');

    $mail = $sender->createMailer();

    //Server settings										// Enable verbose debug output
    $mail->isSMTP();                                    	// Set mailer to use SMTP
    $mail->Host = 'smtp.mail.ru';  							// Specify main and backup SMTP servers
    $mail->SMTPAuth = true;                             	// Enable SMTP authentication
    $mail->Username = '[email protected]';                   	// SMTP username
    $mail->Password = 'password';                       	// SMTP password
    $mail->SMTPSecure = 'ssl';                          	// Enable TLS encryption, `ssl` also accepted
    $mail->Port = 465;                                  	// TCP port to connect to

    /* Other parameters and functions to configuration instanse of PHPMailer */
	
	//Send mails to Server part
    $send = $sender->send();

	//Debug messages
    foreach ($sender->getMessages() as $message) {
        echo $message;
    }
	
	$result = $sender->getResult();
} catch (\Exception $e) {
    echo $e->getMessage();
}




    if (! isset($_POST['mailer'])) {
        throw new Exception('Not data are send');
    }

    $mailerData = (string) $_POST['mailer'];

    $mailer = new \UralMas\ExternalMailer\Server($mailerData);

    echo $mailer->getResultSendMail();
} catch (Exception $e) {
    echo $e->getMessage();
}