On www.ppl.ie when you do submit vacancy, an input form is displayed. It allows the user to attach a file (usually Word doc) and submit to the website owners.
The form is submitted via SMTP using Pear::Mail (code is below). The body of the mail is not being displayed. I can send previous code (non-SMTP) where the body of the mail was being displayed but the attachment was not working
here’s the code:
<?php
if($_POST['submit_vacancy'])
{
if(!$_POST['company'])
$error[] = ‘Input company’;
if(!$_POST['contact'])
$error[] = ‘Input contact name’;
if(!$_POST['mail'] && !$_POST['phone'])
$error[] = ‘Input your e-mail or contact number’;
elseif($_POST['mail'] && !eregi(‘^[a-z0-9._-]+at blanked out[a-z0-9._-]+.[a-z]{2,4}$’, $_POST['mail']))
$error[] = ‘Input correct e-mail’;
if(count($error)==0)
{
include(RelativePath . “/inc/pear/Mail.php”);
include(RelativePath . “/inc/pear/Mail/mime.php”);
$html = “Hello! rnA New vacancy has been submitted. rnCompany: $_POST[company] rnName: $_POST[contact] rnContact Number: $_POST[phone] rnE-mail: $_POST[mail] rnWebsite: $_POST[website] rnJob Title: $_POST[jobtitle] rnSalary: $_POST[salary] rnComments: $_POST[comments] rn”;
$crlf = “rn”;
$hdrs = array(
‘From’ => ‘mail address blanked out’,
‘Subject’ => ‘VACANCY SUBMISSION FROM PPL SITE – “‘.$_POST[company].’”‘,
‘CC’ => ‘mail address blanked out’,
‘Reply-To’ => ‘mail address blanked out’
);
$to = ‘mail address blanked out, mail address blanked out’;
$to = $to.”, “.$hdrs['CC'];
$mime = new Mail_mime($crlf);
$mime->setTXTBody($html);
//$mime->setHTMLBody($html);
if($_FILES['attach_spec']['tmp_name'])
$mime->addAttachment($_FILES['attach_spec']['tmp_name'], $_FILES['attach_spec']['type'], $_FILES['attach_spec']['name']);
$body = $mime->get();
$hdrs = $mime->headers($hdrs);
$smtpinfo["host"] = “mail address blanked out”;
$smtpinfo["port"] = “25″;
$smtpinfo["auth"] = true;
$smtpinfo["username"] = “mail address blanked out”;
$smtpinfo["password"] = “mail address blanked out”;
$mail =& Mail::factory(“smtp”, $smtpinfo);
if($mail->send($to, $hdrs, $body))
{
$show_page = “message”;
$smarty->assign(“message”, “Thank you very much for submitting your Vacancy – we will be in contact with you as soon as possible”);
}
else
{
$cms_go_header = “http://”.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'].”?sended=error”;
}
}
}
?>