Csv File Upload using smtp

<?php

include 'Mail.php';
include 'Mail/mime.php' ;

$text = 'Text version of email';
$html = 'HTML version of email’;
$file = ‘file.csv’;
$crlf = “\n”;
$hdrs = array(
‘From’ => ‘you@yourdomain.com’,
‘Subject’ => ‘Test mime message’
);

$mime = new Mail_mime(array(‘eol’ => $crlf));

$mime->setTXTBody($text);
$mime->setHTMLBody($html);
$mime->addAttachment($file, ‘text/plain’);

$body = $mime->get();
$hdrs = $mime->headers($hdrs);

$host = “ssl://smtp.gmail.com”;
$port = “465”;

$username=”;
$password= ”;

$smtp = Mail::factory(‘smtp’,
array (‘host’ => $host,
‘port’ => $port,
‘auth’ => true,
‘username’ => $username,
‘password’ => $password));

//$mail =& Mail::factory(‘mail’);
$smtp->send(‘mazaharul.huq@nazdaqtechnologies.com’, $hdrs, $body);

?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s