Source Code for Me (s-c.me)

Allows you to paste souce code to blogs! Adapted for Twitter! Here is Search Form in case you missed your code.
Tags: Php,$transport,$mailer,$message,$body,$attach, Created At: 10/24/2016 8:27:24 PMViews:

HTML view:
Copy Source | Copy HTML
$transport = Swift_SmtpTransport::newInstance();
$transport->setUsername('login');
$transport->setPassword('password');
 
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance();
$message->setSubject('Hello man!');
$message->setFrom(array('r2d2@example.com'=>'R2D2'));
$message->setTo('c3po@example.com', 'C3PO');
 
$body='<img src="http://example.com/image.jpg">';
$message->setBody($body, 'text/html');
 
$attach=Swift_Attachment::fromPath('/home/example/htdocs/image.jpg');
// Ðº Ð¾Ð±Ñ‹Ñ‡Ð½Ð¾Ð¼Ñƒ Ð°Ñ‚тачу Ð´Ð¾Ð±Ð°Ð²Ð»ÑÐµÐ¼ Ð·Ð°Ð³Ð¾Ð»Ð¾Ð²Ð¾Ðº Content-Location
$attach->getHeaders()->addTextHeader('Content-Location', 'http://example.com/image.jpg');
 
$message->attach($attach);
$mailer->send($message);
 

Based on Manoli.Net's CodeFormatter. Made by Topbot (c) 2008-2017