1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
function sendApplication( $id )
{
global $database, $mosConfig_absolute_path, $mosConfig_live_site, $option, $cfgjl, $mainframe, $my, $Itemid;
$row = new mosJobPosting( $database );
$row->load( $id );
if ( !$row->id )
{
mosRedirect( "$mosConfig_live_site/index.php?option=$option&task=error&msg=" . _JL_NOSUCHJOB );
}
else
{
$tmplvars = get_object_vars( $row );
foreach ( $_REQUEST as $k => $v )
{
$tmplvars["req_$k"] = $v;
}
$tmpl = new mxTemplate( "$mosConfig_absolute_path/components/com_jobline/templates/{$cfgjl['template']}" );
if ( $tmpl->setTemplate( "applicationemail" ) )
{
// store the file information to variables for easier access
$tmp_name= $_FILES['attach']['tmp_name'];
$type = $_FILES['attach']['type'];
$name = $_FILES['attach']['name'];
$size = $_FILES['attach']['size'];
$error = $_FILES['attach']['error'];
$message = '';
$mime_boundary = '';
$tmpl->setVars( $tmplvars );
$tmpl->parseTemplate();
$message = $tmpl->getOutput();
//echo '<br>--<br> 1.' . $message;
// if the upload succeded, the file will exist
if ( file_exists($tmp_name) )
{
//echo '<br>--<br> 2.' . $message;
// generate a random string to be used as the boundary marker
$mime_boundary = "--==Multipart_Boundary_x".md5(mt_rand())."x";
// check to make sure that it is an uploaded file and not a system file
if( is_uploaded_file($tmp_name) )
{
//echo '<br>--<br> 3.' . $message;
$message .= "nn Attachment : $name";
// open the file for a binary read
$file = fopen( $tmp_name,'rb' );
// read the file content into a variable
$data = fread( $file,filesize($tmp_name) );
// close the file
fclose( $file );
// now we encode it and split it into acceptable length lines
$data = chunk_split( base64_encode($data) );
}
// next, we'll build the message body
// note that we insert two dashes in front of the
// MIME boundary when we use it
$message = "This is a multi-part message in MIME format.\n" . "--{$mime_boundary}\n" .
"Content-Type: text/plain;\n\tcharset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 8bit\n\n" . $message . "\n\n";
// now we'll insert a boundary to indicate we're starting the attachment
// we have to specify the content type, file name, and disposition as
// an attachment, then add the file content and set another boundary to
// indicate that the end of the file has been reached
if( $data )
{
$message .= "--{$mime_boundary}\n" . "Content-Type: {$type};\n" .
"name=\"{$name}\"\n" .
"Content-Disposition: attachment;\n" .
"filename=\"{$name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n";
}
$message .= "--{$mime_boundary}--\n";
}
//echo '<br>--<br> <b>4.</b>' . $message;
//$Replyto = '';
// function
//sendEmail( $email, $subject, $message, $fromname, $fromemail, $replyto, $mime_boundary );
sendEmail( $cfgjl['mailfromaddress'], _JL_APPLICATION_SUBJECT, $message, $cfgjl['mailfromname'], $cfgjl['mailfromaddress'], $Replyto, $mime_boundary);
mosRedirect( "$mosConfig_live_site/index.php?option=$option&Itemid=$Itemid&task=thankyou&id=$id" );
}
else
{
showError( _JL_ERRORSETTMPL . ": applicationemail" );
}
}
}
function sendEmail( $email, $subject, $message, $fromname='', $fromemail='', $replyto='', $mime_boundary='')
{
/*if ( function_exists( "mosMail" ) )
{
mosMail($fromemail, $fromname, $email, $subject, $message);
}
else
{*/
// generate a random string to be used as the boundary marker
$headers = "";
if ( trim( $fromemail ) )
{
$headers = "From: $fromname <$fromemail>\r\n";
}
if ( trim( $replyto ) )
{
$headers .= "Reply-To: <$replyto>\r\n";
}
$headers .= "X-Priority: 3\r\n";
$headers .= "X-MSMail-Priority: Low\r\n";
$headers .= "X-Mailer: PHP 4.x \r\n";
if( $mime_boundary )
{
$headers .= "MIME-Version: 1.0\r\n".
"Content-Type: multipart/mixed;\n\t boundary=\"$mime_boundary\"";
}
@mail($email, $subject, $message, $headers);
//}
}
|