Questions? Feedback? powered by Olark live chat software

Tags: , , , , ,

How do i use SMTP for transactional messages ?

Catalin, February 16

Here is a quick example of howto use our servers for sending out transactional messages:

<?
require_once("lib/swift_required.php");
 
$transport = Swift_SmtpTransport::newInstance("HOST.nzmail.eu", 465, "ssl");
$transport->setUsername("USER");
$transport->setPassword("PASS");
 
$mailer = Swift_Mailer::newInstance($transport);
 
$message = Swift_Message::newInstance()
	->setSubject("test")
	->setFrom(array("youremail@example.com" => "Test"))
	->setBody("Ola this is a test !")
	->addPart("<b>Ola this is a HTML test !</b>", "text/html")
	->setTo(array("recipient@example.com" => "Catalin Constantin"));
 
$mailer->send($message);
?>

This example requires PHP and Swiftmailer library.

1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 5.00 out of 5)
Loading ... Loading ...