require_once('class.phpmailer.php');
include('class.smtp.php');
$mail = new PHPMailer();
$body = file_get_contents('index.php');
$body = eregi_replace("[\]",'',$body);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "smtp.gmail.com"; // SMTP server
//$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "tls";
$mail->Host = "smtp.gmail.com"; // sets the SMTP server
$mail->Port = 587; // set the SMTP port for the GMAIL server
$mail->Username = "mail@gmail.com"; // SMTP account username
$mail->Password = "password"; // SMTP account password
$mail->SetFrom('mail@gmail.com', 'First Last');
$mail->AddReplyTo("mail@gmail.pl","First Last");
$mail->Subject = "New Event";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
if ($_FILES['Photo']['error'] == UPLOAD_ERR_OK)
{
$address = "mail@gmail.com";
$mail->AddAttachment($_FILES['Photo']['tmp_name'], $_FILES['Photo']['name']);
$mail->AddEmbeddedImage($_FILES['Photo']['tmp_name'], $_FILES['Photo']['name']);
$mail->AddAddress($address, "John Doe");
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message sent!";
}
}
我认为已经尝试了一切。仍然没有将文件附加到邮件中。任何的想法? 试图附上尺寸小于3mb的照片。已经尝试过附加文字,图片,音频。 我正在使用上传表单。
E:
<form enctype="multipart/form-data" id="new_event" action="event.php" method="post" name="new_event">
<p><label for="Photo">Photo </label><input type="hidden" name="MAX_FILE_SIZE" value="30000" /><input type="file" name="Photo" value="Sarch" /></p>
<input type="submit" name="next1" value="Add Event" />
</form>
发送没有附件的电子邮件。
解决 更改名称=&#34; MAX_FILE_SIZE&#34;值=&#34; 30000&#34; - &GT;命名=&#34; MAX_FILE_SIZE&#34;值=&#34;&#34;