2160 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Exclusive Author
  • Community Moderator
  • Bought between 50 and 99 items
  • Referred between 200 and 499 users
  • Has been a member for 5-6 years
  • Won a Competition
+10 more
mpc Volunteer moderator says
Hi I use such code to send email from Flash contact form but it doesn’t work on my clients server and I don’t know why it works every where else…
<?php $senderName = $_POST['userName'];
$senderEmail = $_POST['userEmail'];
$senderMessage = $_POST['userMsg'];
$emailAddress = $_POST['authorEmail'];

$senderName = stripslashes($senderName);
$senderEmail = stripslashes($senderEmail);
$senderMessage = stripslashes($senderMessage);
$emailAddress = stripslashes($emailAddress);

$to = "$emailAddress";

$from = "$senderEmail";
$subject = "Email from your flipbook";

//Begin HTML Email Message
$message = <<<EOF
<htm?>
<body bgcolor="#FFFFFF">
<b>Name</b>: $senderName<br /><br />
<b>Email</b>: $senderEmail<br /><br />
<b>Message</b>: $senderMessage<br />
</body>

EOF;
//end of message
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
$to = "$to";

mail( $to,  $subject,  $message,  $headers);

exit();
?>

The code is pretty standard, any help will be great!

303 posts
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 1 and 9 users
  • Sold between 100 and 1 000 dollars
  • Syrian Arab Republic
Laith says

Try to use PHPMailer, it’s a great PHP library. http://phpmailer.worxware.com/ download the right version for you, and check the examples in library folder. :P

Cheers

Laith

5082 posts
  • Australia
  • Bought between 100 and 499 items
  • Community Superstar
  • Exclusive Author
  • Has been a member for 3-4 years
  • Interviewed on the Envato Notes blog
  • Microlancer Beta Tester
  • Referred between 1 and 9 users
  • Sold between 1 000 and 5 000 dollars
Australia says

Could it be < htm? > << incorrect format ( I dont do php by the way )

Or user hasnt setup $emailAddress

Or sendmail function isnt installed on server, or incompatible version of php

4335 posts
  • Beta Tester
  • Bought between 10 and 49 items
  • Community Moderator
  • Contributed a Blog Post
  • Contributed a Tutorial to a Tuts+ Site
  • Exclusive Author
  • Grew a moustache for the Envato Movember competition
+6 more
Reaper-Media Volunteer moderator says

The reason as to why it doesn’t work is probably because this client’s server has not been configured to use mail() correctly, i.e. the smtp details for a webserver email address have not been setup on the server by the host.

Try, as laith said, to use PHPMailer, which will allow you to send emails using any smtp credentials :-)

2160 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Exclusive Author
  • Community Moderator
  • Bought between 50 and 99 items
  • Referred between 200 and 499 users
  • Has been a member for 5-6 years
  • Won a Competition
+10 more
mpc Volunteer moderator says

The reason as to why it doesn’t work is probably because this client’s server has not been configured to use mail() correctly, i.e. the smtp details for a webserver email address have not been setup on the server by the host. Try, as laith said, to use PHPMailer, which will allow you to send emails using any smtp credentials :-)

This is strange but I am trying with the PHPMailer with no luck ;/

4335 posts
  • Beta Tester
  • Bought between 10 and 49 items
  • Community Moderator
  • Contributed a Blog Post
  • Contributed a Tutorial to a Tuts+ Site
  • Exclusive Author
  • Grew a moustache for the Envato Movember competition
+6 more
Reaper-Media Volunteer moderator says


The reason as to why it doesn’t work is probably because this client’s server has not been configured to use mail() correctly, i.e. the smtp details for a webserver email address have not been setup on the server by the host. Try, as laith said, to use PHPMailer, which will allow you to send emails using any smtp credentials :-)
This is strange but I am trying with the PHPMailer with no luck ;/

are you getting any error messages and have you tried sending via smtp? :)

2160 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Exclusive Author
  • Community Moderator
  • Bought between 50 and 99 items
  • Referred between 200 and 499 users
  • Has been a member for 5-6 years
  • Won a Competition
+10 more
mpc Volunteer moderator says



The reason as to why it doesn’t work is probably because this client’s server has not been configured to use mail() correctly, i.e. the smtp details for a webserver email address have not been setup on the server by the host. Try, as laith said, to use PHPMailer, which will allow you to send emails using any smtp credentials :-)
This is strange but I am trying with the PHPMailer with no luck ;/
are you getting any error messages and have you tried sending via smtp? :)

no error, yeah I think it was via smtp….

4335 posts
  • Beta Tester
  • Bought between 10 and 49 items
  • Community Moderator
  • Contributed a Blog Post
  • Contributed a Tutorial to a Tuts+ Site
  • Exclusive Author
  • Grew a moustache for the Envato Movember competition
+6 more
Reaper-Media Volunteer moderator says




The reason as to why it doesn’t work is probably because this client’s server has not been configured to use mail() correctly, i.e. the smtp details for a webserver email address have not been setup on the server by the host. Try, as laith said, to use PHPMailer, which will allow you to send emails using any smtp credentials :-)
This is strange but I am trying with the PHPMailer with no luck ;/
are you getting any error messages and have you tried sending via smtp? :)
no error, yeah I think it was via smtp….

Care to share the code that you used php mailer with? :-)

2160 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Exclusive Author
  • Community Moderator
  • Bought between 50 and 99 items
  • Referred between 200 and 499 users
  • Has been a member for 5-6 years
  • Won a Competition
+10 more
mpc Volunteer moderator says





The reason as to why it doesn’t work is probably because this client’s server has not been configured to use mail() correctly, i.e. the smtp details for a webserver email address have not been setup on the server by the host. Try, as laith said, to use PHPMailer, which will allow you to send emails using any smtp credentials :-)
This is strange but I am trying with the PHPMailer with no luck ;/
are you getting any error messages and have you tried sending via smtp? :)
no error, yeah I think it was via smtp….
Care to share the code that you used php mailer with? :-)

Sure, I used something like this with static emails just to check if it works…

<?php include_once('class.phpmailer.php');

$senderName = $_POST['userName'];
$senderEmail = $_POST['userEmail'];
$senderMessage = $_POST['userMsg'];
$emailAddress = $_POST['authorEmail'];

$senderName = stripslashes($senderName);
$senderEmail = stripslashes($senderEmail);
$senderMessage = stripslashes($senderMessage);
$emailAddress = stripslashes($emailAddress);

$mail             = new PHPMailer();
$body             = $mail?>getFile('contents.html');
$body             = eregi_replace("[\]",'',$body);

$mail->IsSendmail(); // telling the class to use SendMail transport

$mail->From       = "magazinempc@gmail.com";
$mail->FromName   = "Magazine MPC";

$mail->Subject    = "PHPMailer Test Subject via smtp";

$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);

$mail->AddAddress("fern666@gmail.com", "Fern");

if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
}

?>
4335 posts
  • Beta Tester
  • Bought between 10 and 49 items
  • Community Moderator
  • Contributed a Blog Post
  • Contributed a Tutorial to a Tuts+ Site
  • Exclusive Author
  • Grew a moustache for the Envato Movember competition
+6 more
Reaper-Media Volunteer moderator says

Yeah you’re not using smtp with that, your just letting PHPMailer setup the php mail() function for you, what you need to do is try to set some SMTP credentials before you call $mail->Send()

try to add something like this (with real smtp info)
$mail->IsSMTP(); // telling the class to use SMTP
// if the smtp server requires authentication (eg. start tls)...
/*
    $mail->SMTPAuth     = true;                  // enable SMTP authentication
    $mail->SMTPSecurity = "starttls";
    $mail->SMTPSecure   = "starttls";
*/
$mail->Host       = "mail.server.com"; // sets the SMTP server
$mail->Port       = 25;                    // set the SMTP port for the server
$mail->Username   = "someone @ server.com"; // SMTP account username
$mail->Password   = "password";        // SMTP account password

Good luck :-)

EDIT :

Also, you can play around with the debugging for PHP Mailer for when it tried to connect to the smtp server:
$mail->SMTPDebug = 0; // (0/1/2)
by
by
by
by
by
by