Contact Form PHP to SMTP

Hello,

I’ve this contact form in a theme, but my hosting doens’t support php mail, and told me to use smtp instead.
Can anyone help-me? Its the last think that is still not working.

I’ve installed the WP-Mail-SMTP pluging.

Thanks in advance

[php]<?php
?>

<?php $nameError = ''; $emailError = ''; $commentError = ''; if(isset($_POST['submitted'])) { if(trim($_POST['contactName']) === '') { $nameError = 'Please enter your name.'; $hasError = true; } else { $name = trim($_POST['contactName']); } if(trim($_POST['email']) === '') { $emailError = 'Please enter your email address.'; $hasError = true; } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) { $emailError = 'You entered an invalid email address.'; $hasError = true; } else { $email = trim($_POST['email']); } if(trim($_POST['comments']) === '') { $commentError = 'Please enter a message.'; $hasError = true; } else { if(function_exists('stripslashes')) { $comments = stripslashes(trim($_POST['comments'])); } else { $comments = trim($_POST['comments']); } } if(!isset($hasError)) { $emailTo = get_option('of_email'); if (!isset($emailTo) || ($emailTo == '') ){ $emailTo = get_option('admin_email'); } $subject = 'Message from '.$name; $body = "Name: $name \n\nEmail: $email \n\nComments: $comments"; $headers = 'From: '.$name.' <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email; mail($emailTo, $subject, $body, $headers); $emailSent = true; } } ?> <?php get_header(); ?>
<div id="content">
	<div class="user-content">
		<?php if (get_option('of_titles_off') == "false") { ?>
			<h1 class="page-titles"><span><?php the_title(); ?></span></h1>
		<?php } ?>
		
		<div class="two_third">
			<?php if (have_posts()) : ?>
				<?php while (have_posts()) : the_post(); ?>
				<?php endwhile; ?>
			<?php endif; ?>
			
			<?php if(isset($emailSent) && $emailSent == true) { ?>
					<div class="message success nospace">
						<h2>Thanks</h2>
						<p>Your email was sent successfully, we'll get back to you as soon as possible.</p>
					</div>
					<?php } else { ?>
						<?php the_content(); ?>
						<?php if(isset($hasError) || isset($captchaError)) { ?>
							<p class="error">Sorry, an error occured.<p>
					<?php } ?>
			
				<div id="contact-form">
					<form action="<?php the_permalink(); ?>" id="contactForm" method="post">
						<ul>
							<li>
								<?php if($nameError != '') { ?>
									<span class="error"><?php echo $nameError;?></span>
								<?php } ?>
								<label for="contactName">Name<div class="contact-arrow"></div></label>
								<input type="text" name="contactName" id="contactName" value="<?php if(isset($_POST['contactName'])) echo $_POST['contactName'];?>" class="required requiredField" />
							</li>
							<li>
								<?php if($emailError != '') { ?>
									<span class="error"><?php echo $emailError; ?></span>
								<?php } ?>
								<label for="email">Email<div class="contact-arrow"></div></label>
								<input type="text" name="email" id="email" value="<?php if(isset($_POST['email']))  echo $_POST['email'];?>" class="required requiredField email" />
							</li>
							<li>
								<?php if($commentError != '') { ?>
									<span class="error"><?php echo $commentError;?></span>
								<?php } ?>
								<label class="message-area" for="commentsText">Message<div class="contact-message-arrow"></div></label>
								<textarea name="comments" id="commentsText" rows="7" cols="30" class="required requiredField"><?php if(isset($_POST['comments'])) { if(function_exists('stripslashes')) { echo stripslashes($_POST['comments']); } else { echo $_POST['comments']; } } ?></textarea>
							</li><br />
							<li>
								<button type="submit" class="button">Send</button>
							</li>
						</ul>
						<input type="hidden" name="submitted" id="submitted" value="true" />
					</form>
					<?php } ?>
				</div><!--end #contact-form-->
			</div><!-- end .two-thirds-->
			
			<div class="one_third last">
				<?php if(get_option('of_contact_address') != "") { ?><p class="contact-icon address"><?php echo get_option('of_contact_address'); ?></p><?php } ?>
				<?php if(get_option('of_contact_phone') != "") { ?><p class="contact-icon phone"><?php echo get_option('of_contact_phone'); ?></p><?php } ?>
				<?php if(get_option('of_contact_phone_alt') != "") { ?><p class="contact-icon phone-alt"><?php echo get_option('of_contact_phone_alt'); ?></p><?php } ?>
				<?php if(get_option('of_email') != "") { ?><p class="contact-icon email"><?php echo get_option('of_email'); ?></p><?php } ?>
			
				<?php if(get_option('of_maps_location') != "") { ?>
					<div class="divider"></div>
					<p class="contact-icon location">Our location</p>
					<img class="border" src="http://maps.googleapis.com/maps/api/staticmap?center=<?php echo get_option('of_maps_location') ?>&size=268x<?php echo get_option('of_maps_height') ?>&zoom=<?php echo get_option('of_maps_zoom') ?>&sensor=false&maptype=<?php echo get_option('of_maps_type') ?>&markers=<?php echo get_option('of_maps_location') ?>" />
				<?php } ?>
			</div>

	</div><!--end .user-content-->
</div><!-- end #content -->		
<?php get_footer(); ?>[/php]

Here is the link for the form itself. It says send, if anyone tries, but doesn’t deliver them.

http://gomotoys.com/?page_id=13

Sponsor our Newsletter | Privacy Policy | Terms of Service