So following on from their example, once you've composed your email with attachment or whatever, you'll probably want to send it.
since imap_mail(...) takes the message as body and re-encodes it, ignoring all the hard work you've done already.
Only real solution I found is to post it yourself:
// open connect to mail server
$socket=socket_create(AF_INET,SOCK_STREAM,SOL_TCP);
if ($socket===false) {
die('Error: socket_create, '.socket_strerror(socket_last_error()));
}
$server="myserver.com"; // say 10.0.0.1 or whatever your mail sever is
$port=25; // again your mail server port, here generic smtp
if (socket_connect($socket,$server,$port)) {
print "Connection successful\n";
}else {
die('Error: socket_connect, '.socket_strerror(socket_last_error()));
}
// send it...
socket_write($socket,"HELO {$envelope["from"]}\n");
socket_write($socket,"MAIL FROM: {$envelope["from"]}\n");
socket_write($socket,"RCPT TO: {$envelope["to"]}\n");
socket_write($socket,"DATA\n");
socket_write($socket,"$message\n");
socket_write($socket,".\n");
socket_write($socket,"QUIT\n");
// done...
socket_close($socket);
Ofcourse the shell may work for you?
echo "Hello World" | mail -s "Greeting..." -a "attachSomeFile.txt" gspot@gmail.com