Skip to content

Instantly share code, notes, and snippets.

@folmert
Last active August 29, 2015 14:22
Show Gist options
  • Save folmert/77373ffa22729b470372 to your computer and use it in GitHub Desktop.
Save folmert/77373ffa22729b470372 to your computer and use it in GitHub Desktop.
<?php
# https://github.com/PHPMailer/PHPMailer/archive/master.zip
# set_include_path(__DIR__);
# include('./libs/PHPMailer-master/PHPMailerAutoload.php');
$mail = new PHPMailer(true);
$mail->IsSMTP();
$mail->CharSet = "UTF-8";
# ____________________________________/ custom
$mail->SetFrom('[email protected]', 'YOURVALUE.pl');
$mail->AddAddress('YOURVALUE');
$mail->addCC('[email protected]');
$mail->addBCC('[email protected]');
$mail->Subject = 'YOURVALUE';
$mailContent = "YOURVALUE";
$mail->Host = 'smtp.gmail.com';
$mail->Username = "[email protected]";
$mail->Password = "YOURVALUE";
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
# ____________________________________custom /
$mail->SMTPDebug = 0;
$mail->Debugoutput = 'html';
$mail->SMTPAuth = true;
$mail->ContentType = 'text/html; charset=UTF-8';
$mail->Body = "<html><body>";
$mail->Body .= "$mailContent";
$mail->Body .= "</body></html>";
$mail->WordWrap = 50;
# ____________________________________/ attachments
// for file upload form must have attribute: enctype="multipart/form-data"
if($_FILES['file']['tmp_name']) {
$zipdir = '../zips/';
$zipname = 'plan_budynku_'.$data_przeslania.'_'.$nazwisko.'.zip';
$zippath = $zipdir.$zipname;
$zip = new ZipArchive;
$zip->open($zippath, ZipArchive::CREATE);
foreach ($_FILES['file']['tmp_name'] as $key => $tmpName) {
$zip->addFile($tmpName,$_FILES['file']['name'][$key]);
}
$zip->close();
$mail->AddAttachment($zippath, $zipname);
}
# ____________________________________attachments /
$send = $mail->Send();
if($send) {
echo "Success";
}
else {
echo "Error";
}
$mail->ClearAllRecipients();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment