2195 posts
  • Has referred 200+ members
  • Has sold $500,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+13 more
mpc 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
  • Has been part of the Envato Community for over 5 years
  • Has referred 1+ members
  • Has sold $100+ on Envato Market
  • Has collected 1+ items on Envato Market
+2 more
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

5492 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Located in Australia
  • Has sold $1,000+ on Envato Market
+4 more
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
  • Has been part of the Envato Community for over 6 years
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Has been a beta tester for an Envato feature
+10 more
Reaper-Media 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 :-)

2195 posts
  • Has referred 200+ members
  • Has sold $500,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+13 more
mpc 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
  • Has been part of the Envato Community for over 6 years
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Has been a beta tester for an Envato feature
+10 more
Reaper-Media 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? :)

2195 posts
  • Has referred 200+ members
  • Has sold $500,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+13 more
mpc 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
  • Has been part of the Envato Community for over 6 years
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Has been a beta tester for an Envato feature
+10 more
Reaper-Media 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? :-)

2195 posts
  • Has referred 200+ members
  • Has sold $500,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+13 more
mpc 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
  • Has been part of the Envato Community for over 6 years
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Has been a beta tester for an Envato feature
+10 more
Reaper-Media 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