I have just upgraded from 2.1.17 to 3.2.4 and was trying to test attachments ...
Here is what I got.
Code: Select all
Fatal error:
Uncaught Error of type [swift_fileexception] with message [No such file 'orcut.jpg']
@0 swift_file::swift_file() in /home/usr/public_html/post.php on line 81
@1 swift_file::setpath() in /home/usr/public_html/Swift-3.2.4-php4/Swift/File.php on line 52
in /home/usr/public_html/Swift-3.2.4-php4/Swift/Errors.php on line 99Thanks.
The full code, by the way ...
Code: Select all
$objetcordo=stripslashes($_POST['objet-cordo']);
$themessage=htmlentities($_POST['themessage'],ENT_QUOTES);
$sender = $prenom.' '.$nom.' <'.$email.'>';
$recipients = $_POST['moncor'];
if (is_uploaded_file($_FILES['dossier']['tmp_name'])) { ############ if a file is submitted
set_time_limit(8000);
$allowed_types = array(".pdf", ".doc", ".txt", ".xls", ".ppt", ".jpg", ".jpeg", ".pjpeg", ".png", ".x-png");
$uploadfile=$_FILES['dossier']['tmp_name'];
$uploadname=$_FILES['dossier']['name'];
$uploadtype=$_FILES['dossier']['type'];
$pos = strrpos($uploadname, '.');
$extension = substr($uploadname, $pos);
if(!in_array($extension, $allowed_types)) {
########### Error messages ...
}
if ($extension == ".pdf") { $mymime = "application/pdf"; } else
if ($extension == ".doc") { $mymime = "application/msword"; } else
if ($extension == ".txt") { $mymime = "text/plain"; } else
if ($extension == ".xls") { $mymime = "application/excel"; } else
if ($extension == ".ppt") { $mymime = "application/mspowerpoint"; } else
if ($extension == ".jpg") { $mymime = "image/jpeg"; } else
if ($extension == ".jpeg") { $mymime = "image/jpeg"; } else
if ($extension == ".pjpeg") { $mymime = "image/pjpeg"; } else
if ($extension == ".png") { $mymime = "image/png"; } else
if ($extension == ".x-png") { $mymime = "image/png"; }
}
require_once "Swift-3.2.4-php4/Swift.php"; ### lib/ renamed as Swift-3.2.4-php4/
require_once "Swift-3.2.4-php4/Swift/Connection/NativeMail.php";
$swift =& new Swift(new Swift_Connection_NativeMail());
$message =& new Swift_Message($objetcordo);
$message->attach(new Swift_Message_Part($themessage, "text/html"));
$message->attach(new Swift_Message_Attachment(new Swift_File($uploadname), $uploadname, $mymime));
$recipientz =& new Swift_RecipientList();
$recipientz->addTo($email);
foreach ($recipients as $recipient) {
if ($recipient != '') {
$recipientz->addBcc($recipient);
}
}
if ($swift->send($message, $recipients, new Swift_Address($email, $prenom.' '.$nom) )) {
?>
<h5 align="center" style="color:#006DC6;">Mail envoyé</h5>
Bonjour <?=$prenom?> <?=$nom?><br /><br />
Votre mail à bien été envoyée à<br />
Veuillez noter que une copie de ce message vous sera automatiquement envoyée<br />
<br />
<?php
} else {
print '<div align="center" style="color:#FF0000;font-size:21px;">Erreur ... veuillez essayer ultérieurement</div>';
}
$swift->disconnect();
}