/    Sign up×
Community /Pin to ProfileBookmark

Getting mail() to send my emails

Hey Gents,

Here is my Issue, i’m getting an error trying to get my form to submit and send emails. The development site is at [url]www.marinetechegypt.com/contact.php[/url]

I tried it locally on my WAMP first, it wasn’t sending so i decided to test on the server incase its a local config issue.

I just get an error from the If condition for if(isset($_POST[‘submit’])) {]. Im really trying my best to solve this but i’m not sure what i’m missing! any help would be greatly appreciated, thx ?

The HTML:

[code=html] <div class=”col one-half”>
<h3> Send us an Email </h3>
<div class=”ajax_message”></div>
<form class=”contact-form” method=”post” action=”php-mailer.php”>
<input type=”hidden” name=”ac” value=”login” />
<p>
<label for=”fname”> Your Name <span class=”required”> * </span> </label>
<input type=”text” name=”fname” class=”input-short” id=”fname” placeholder=”Your Full Name” />
<?php if(isset($errName1)) echo $errName1; ?>
</p>
<p>
<label for=”email”> Your Email <span class=”required”> * </span> </label>
<input type=”text” name=”email” class=”input-long” id=”email” placeholder=”Your Email” />
<?php if(isset($errEmail)) echo $errEmail; ?>
</p>
<p>
<label> Subject </label>
<input name=”subject” type=”text” id=”subject” class=”input-short” placeholder=”Subject”/>
</p>
<p>
<label for=”message”> Your Message <span class=”required”> * </span> </label>
<textarea name=”message” class=”textarea-message” id=”textarea” placeholder=”Your Message”></textarea>
<?php if(isset($errMessage)) echo $errMessage; ?>
</p>
<p><input name=”submit” type=”submit” value=”Send Message” class=”button small grey contact-submit” /></p>
</form>
<div class=”error-container” style=”display:none;”> Please fill the above required fields correctly! </div>
</div>[/code]

phpmailer file: are there missing dependencies for this php function or what? Ive changed the adressed to hide the emails and such

[CODE]<?php
if(isset($_POST[‘submit’])) {
$to = “[email protected]”;
$subject = “Marinetech Egypt Contact Form”;
$first_name_field = $_POST[‘fname’];
$email_field = $_POST[’email’];
$message = $_POST[‘textarea’];
$message = ‘<!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></head>
<body>
<table>
<tr><td>Name</td><td>’ . $first_name_field . ‘</td></tr>
<tr><td>Email</td><td>’ . $email_field . ‘</td></tr>
<tr><td>Website</td><td>’ . $subject . ‘</td></tr>
<tr><td>Comment</td><td>’ . nl2br($message) . ‘</td></tr>
</table>
</body>
</html>’;

$headers = ‘MIME-Version: 1.0’ . “rn”;
$headers .= ‘Content-type: text/html; charset=iso-8859-1’ . “rn”;

// Additional headers
$headers .= ‘To: <[email protected]>’ . “rn”;
$headers .= ‘[From] <[email protected]>’ . “rn”;

// Mail it

ini_set(‘SMTP’,’mbox.freehostia.com’);
ini_set(‘smtp_port’,’25’);
// ini_set(‘username’ , ‘[email protected]’);
// ini_set(‘password’ , ‘XXXXXXXX’);
// ini_set(‘sendmail_from’,’[email protected]’);

mail($to, $subject, $message, $headers);
include(‘index.html’);
} else {
echo “Error”;
}
?>[/CODE]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@SabzauthorApr 30.2013 — Hello heloo hello.. i can here my echo in here ?

Can som1 atleast pont me in the direction for a working php mailer script. preferably with some validation also ?

Ive tried so many edits to make it work, by adding ini settings for the smtp authentication ..etc still no lock just get a error and the emails aren't delivered.
Copy linkTweet thisAlerts:
@ZABIMay 02.2013 — what error message do you get ?
×

Success!

Help @Sabz spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...