<?php
set_time_limit(0);
error_reporting(E_ALL);
//Load in the files we'll need
require_once "lib/Swift.php";
require_once "lib/Swift/Connection/SMTP.php";
//Start Swift
$smtp =& new Swift_Connection_SMTP("smtp.gmail.com", SWIFT_SMTP_PORT_SECURE, SWIFT_SMTP_ENC_TLS);
$smtp->setUsername("test@gmail.com");
$smtp->setPassword("aaaaaaaaaaaaaaaaaaaaaaa");
$swift =& new Swift($smtp);;
$message =& new Swift_Message("My subject");
$message->attach(new Swift_Message_Part("I have attached a file to this message!"));
//Use the Swift_File class
$message->attach(new Swift_Message_Attachment("aaaaaaa"), "aaaaaa", "application/x-gzip");
//Now check if Swift actually sends it
if ($swift->send($message, "test@test.com", "test@gmail.com")) echo "Sent";
else echo "Failed";
?>
It keeps on sending me a file called "file.att.0" instead of the actual file. I tried putting in the file extension, didn't work either. The MIME type is application/x-gzip, I've checked in Nautilus. The file in question is ~7 MB.
I tried with a smaller text file, but that worked.
The attachment class takes a string which is the file contents, otherwise it takes a stream as an instance of Swift_File. Your version was passing a string which will become the file contents, however your string is just "aaaaaa" which I guess is your filename.