I have a form and I want to place the received data from the form into a .txt file and attach to the mail. Without saving to the server. How to create and attach this file to the mail? Looking at the example that comes with PHPMailer I do not find the answer to my question.
< php
if ($_POST[ 'message' ] == '' ) {
$nosketch = '<p>The user has not provided sketch.</p>';
} else {
$body .= "\n\n--" . $bound . "\n";
$attachment = $_POST[ 'message' ];
$file_name = "mol_" . time() . ".txt";
$body .= "Content-Type: text/plain; name=" . $file_name . "\n";
$body .= "Content-Transfer-Encoding: 8bit\n";
$body .= "Content-Disposition: attachment\n\n";
$body .= $attachment . "\n";
$body .= "--" . $bound . "--\n\n";
$mailer->AddAttachment();
};
require 'mailer/PHPMailerAutoload.php';
$mailer = new PHPMailer;
$mailer->setFrom( $_POST[ 'email1' ], $_POST[ 'name' ] );
$mailer->addAddress( 'name1@email.com' );
$mailer->AddCC( 'name1@email.com' );
$mailer->Subject = 'User ' . $_POST[ 'name' ] . ' submit';
$mailer->isHTML( true );
$mailer->Body = $_POST[ 'name' ] . '<br/>' . $_POST[ 'message' ];
$mailer->send();
?>