Hi All,
I'm really fresh to PHP coding and I've got a problem with some forms we've been using for some of our sites.
I was given a set of PHP forms from an ex-colleague of mine and it all works fine except we get really interesting output in the emails when the form is sent. Here is an example of what ends up in our inbox after a mail is sent:
Someone applied for the Tests Authorized Reseller Program=20
From:=
Jim Test
Email Address: jim@testemail.com
Phone Num=
ber: (555) 555-5555
Job Title: Designer
Company Name: Log=
o Design
Address: 5 828 67 Avenue SW
City: Moncton
Provin=
ce or State: Alberta
Country: Canada
Company Website: logo=
.ca
Company Size: 1-5
Industry: Education
Comment /=
Question
L=
orem ipsum dolor sit amet, consectetur adipiscing elit. Fusce vel quam n=
on neque semper euismod. Nunc nec neque massa, quis adipiscing purus. Se=
d at orci dolor, et varius sapien. Vestibulum ante ipsum primis in fauci=
bus orci luctus et ultrices posuere cubilia Curae; In mollis, diam et rh=
oncus mollis, lacus sapien imperdiet velit, quis consequat nunc tortor v=
el mi. Fusce blandit iaculis dapibus. Praesent viverra viverra velit, qu=
is adipiscing nulla ornare eget. Praesent augue justo, sollicitudin at d=
ignissim tempor, luctus ut purus. Donec eros felis, tincidunt sed cursus=
sit amet, gravida porttitor lectus. Vivamus luctus risus a erat convall=
is eu auctor sapien sagittis. Sed venenatis sem magna, malesuada malesua=
da nisl. Etiam ac erat nisl, et pellentesque diam. Curabitur a risus sit=
amet risus porta tempor vel eu tellus. Phasellus id dui a lectus sodale=
s fermentum. Praesent tincidunt blandit leo id faucibus. Vivamus molesti=
e convallis nulla a aliquet.
So as you can see, we are getting some strange line breaks in the information preceded by an "=" sign. I've shown it to a couple different developers and we haven't been able to make heads or tales of it so I thought I would toss out to the internet. Please, any information or guidance would be greatly appreciated. I will include a sample of the code for the email constructor below. Thanks in advance for the help!
<?php
class testForm {
//general variables
var $body;
//constructor
function testForm(){ }
//create the body of the email
function set_body(){
$this->body = "";
// If email_confirm field not empty mark message as possible spam
if( isset($_POST['rf-email-confirm']) && $_POST['rf-email-confirm'] != "") {
$this->body .= "////////////////////////////////////////////////////////\r\n\r\n";
$this->body .= "Message is possible SPAM!\r\n\r\n";
$this->body .= "////////////////////////////////////////////////////////\r\n\r\n";
}
$this->body .= "Someone applied for the Tests Authorized Reseller Program \r\n\r\n";
$this->body .= 'From: ' . str_replace("\'","'",$_POST['rf-fname']) ." ". $_POST['rf-lname'] . "\r\n";
$this->body .= 'Email Address: ' . str_replace("\'","'",$_POST['rf-email']) . "\r\n";
$this->body .= 'Phone Number: ' . str_replace("\'","'",$_POST['rf-phone']) . "\r\n";
$this->body .= 'Job Title: ' . str_replace("\'","'",$_POST['rf-title']) . "\r\n\r\n";
$this->body .= 'Company Name: ' . str_replace("\'","'",$_POST['rf-company']) . "\r\n";
$this->body .= 'Address: ' . $_POST['rf-address'] . "\r\n";
$this->body .= 'City: ' . $_POST['rf-bcity'] . "\r\n";
$this->body .= 'Province or State: ' . $_POST['rf-prov'] . "\r\n";
$this->body .= 'Country: ' . $_POST['rf-country'] . "\r\n";
$this->body .= 'Company Website: ' . $_POST['rf-url'] . "\r\n";
$this->body .= 'Company Size: ' . $_POST['rf-employees'] . "\r\n";
$this->body .= 'Industry: ' . $_POST['rf-industry'] . "\r\n\r\n";
if($_POST['rf-message'] != '')
{
$this->body .= "Comment / Question\r\n";
$this->body .= "---------------------------------------------------\r\n";
$this->body .= str_replace("\\", "", $_POST['rf-message']) . "\r\n\r\n";
}
$this->body = str_replace("\'","'",$this->body);
return $this->body;
}
//send e-mail
function send_email() {
require_once($_SERVER['DOCUMENT_ROOT'] . '/classes/lib/swift_required.php');
$toEmail = "test@testemail.com";
$fromName = str_replace("\'","'",$_POST['rf-fname']) ." ". $_POST['rf-lname'];
$message = Swift_Message::newInstance();
$message->setSubject('Tests Contact Form');
$message->setFrom(array($_POST['rf-email'] => $fromName));
$message->setTo( array($toEmail => 'TestMail') );
$message->setBody($this->set_body());
$transport = Swift_MailTransport::newInstance();
$mailer = Swift_Mailer::newInstance($transport);
if($result = $mailer->send($message)) {
return true;
}
return false;
}
}
?>