Изпращане на файл на e-mail

ivo75

Registered
Как мога да изпратя файл на е-маил т.е. директно да го изпратя, а не чрез форма за прикачване. Искам да го направя чрез Cron Job от хостинга. Ако някой разполага с някакъв скрипт нека да го сподели ще се радвам много
 
Гледаш примерно от тук, но вместо да ползваш $_FILES['att']['tmp_name'] зареждаш направо пътя до файла, който искаш да изпратиш.
Предполагам с кронджоб-а няма да имаш толкова проблеми :?:
 
нещо не стана получих ето това:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<title>��������� �� E-Mail � �������� ����</title>
<style type="text/css">
body{
background-color:#FFFFFF;
color:#000000;
font-size:10px;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
a{
background-color: #FFFFFF;
font-family: verdana;
font-size: 10px;
text-decoration: none;
text-align:center;
color:#000000;
}
a:hover{
text-decoration: underline;
background-color: #99CC00;
}
table{border:1px dashed #000000;}
td{border-bottom:1px dashed #000000;}
.text{padding-top: 8px;}
textarea,input{border:1px dotted #000000;}
</style>
</head>

<body>
<form action="?act=send" method="post" enctype="multipart/form-data">
<table width="40%" border="0">
<tr>
<td align="center" scope="row">��</td>
<td valign="top"><input name="from_txt" type="text" size="30" maxlength="30" value="" /></td>
</tr>
<tr>
<td align="center" scope="row">����</td>
<td valign="top"><input name="subject" type="text" size="30" maxlength="30" value="" /></td>
</tr>
<tr>
<td align="center" valign="top" class="text" scope="row">�����������</td>
<td valign="top"><p>
<textarea name="suob" cols="40" rows="20"></textarea>
</p> </td>
</tr>
<tr>
<td align="center" scope="row">����������� �� ����?</td>
<td><input type="file" name="att"></td>
</tr>
<tr align="center" valign="top">
<th colspan="2" scope="row">
<input name="send" type="submit" value="�������" /></th>
</tr>
</table>


</form>
</body>
</html>
 
dhtodorov каза:
PHPMailer и живота става по-приятен.

Дава ми това съобщение

Warning: file_get_contents(contents.html): failed to open stream: No such file or directory in /home/souvapca/public_html/mail1.php on line 8
Could not access file: u4eb.xls
Could not access file: u4eb.xls
Message body empty
Mailer Error: Message body empty
 
Хора последно получих това на е-майла си: като грешка от Cron Jobs-a

<html>
<head>
<title>PHPMailer - SMTP (Gmail) advanced test</title>
</head>
<body>

<strong>Could not access file: ucheb.xls</strong><br />

</body>
</html>

явно няма достъп до файла който искам да пратя, но не знам защо

ето и целия код който използвам

<pre>

<html>
<head>
<title>PHPMailer - SMTP (Gmail) advanced test</title>
</head>
<body>

<?php
require_once('PHPMailer/class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch

$mail->IsSMTP(); // telling the class to use SMTP

try {
$mail->Host = "mail.imeto_ba_sayta_mi"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "mail.imeto_ba_sayta_mi"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "potrebitelsko_ime"; // GMAIL username
$mail->Password = "parola"; // GMAIL password
$mail->AddReplyTo('e-mail na podatel', 'First Last');
$mail->AddAddress('e-mail na polu4atel', 'John Doe');
$mail->SetFrom('e-mail na podatel', 'First Last');
$mail->AddReplyTo('e-mail na podatel', 'First Last');
$mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
//$mail->MsgHTML(file_get_contents('contents.html'));
$mail->AddAttachment('ucheb.xls'); // attachment
$mail->AddAttachment('ucheb.xls'); // attachment
$mail->Send();
echo "Message Sent OK</p>\n";
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
?>

</body>
</html>

</pre>
 

Back
Горе