Need help with mail

roelofs88

No avatar

2006-11-08 20:55

Hi,

The email funtion on my quick card website does not work.
After searching a little I found out that the company where I host my website does accept the mail() function but only if there is a "from header".

Such as:


$headers 
"From: me <me@me.com>\n";


Our something like that.
So my questions are, What code do I use en Where do I insert this code?

I hope everything is clear, if not please ask me if you need more information.

Thanks in advance,

Kevin

Claps

Avatar: Claps

2006-11-09 08:05

roelofs88 - if you look in core/other.php to function SendMail you'll find a line
@mail( $sTargetEmail, $sTopic, $sMailContent, 'From: '.$sSender ), so the headers are already there ('From: '.$sSender ). You could try to remove @ in front and send a mail again and a error message will pop. Maybe this error message will tell more.

roelofs88

No avatar

2006-11-09 19:31

I still get the same message, that there was an error.
Also I forgot to mention it's about mail on the contact page.
The page where users can send email's to me via de webbrowser.

Does that page have a From header?

I hope someone can help me,

Kevin

Claps

Avatar: Claps

2006-11-09 19:34

roelofs88 - try http://opensolution.org/Quick.Cart/docs/en/?id=tips, look for mail() function replacement in Contact page

roelofs88

No avatar

2006-11-10 19:52

It still doesn't work.
This is what the hosting company says: (translated

Our application has no changes that have a big impact with the use of the mail() function.
It does however need to meet certain requirements:

The message must contain a "from" header.
from: name | from: user@domain;
The domain that is named in the from header must be known at PCextreme( my hosting company).

If the message does not meet the requirements the mail() function will return FALSE and create a PHP WARNING.
The given warning can be suppressed by using the @.

They also give some examples:


<?php

/** 
 * $to    : receiver of the message
 * $subject    : subject of the message
 * $message    : contents of the message
 */
$to "receiver@domain.nl";
$subject "php mail() test";
$message "Text and stuff


/**
 * Example 1
 *
 * This method will FAIL becaus there
 * is nog 'from'header
 */
print (!mail($to, $subject, $message)) ? "
FAIL!" : "SUCCESS!"; // FAIL!


/**
 * Example 2
 *
 * This will fail too because we assume, 'unknown.nl' is not known at PCextreme 
 */
$headers = "
FromAnonymous <user@unknown.nl>\n";
$headers .= ""; // add more headers if needed
print (!mail($to, $subject, $message, $headers)) ? "
FAIL!" : "SUCCESS!"; // FAIL!


/**
 * Example 3
 *
 * The following will work because
 * the domain pcextreme.nl is known as a vhost.
 */
$headers = "
FromPCextreme B.V. <support@pcextreme.nl>\n";
$headers .= ""; // voeg meer headers toe indien gewenst
print (!mail($to, $subject, $message, $headers)) ? "
FAIL!" : "SUCCESS!"; // SUCCESS!


/**
 *Example 4
 *
 * The following messae will be apporved.
 * If a sender is known at PCextreme, if a user replies to this message, 
*the reaction will be sent to user@unknown.nl
 */
$headers = "
FromPCextreme B.V. <support@pcextreme.nl>\n";
$headers .= "
Reply-touser@unknown.nl\n";
print (!mail($to, $subject, $message, $headers)) ? "
FAIL!" : "SUCCESS!"; // SUCCESS!

?>



This is all the info I have,

Sorry to keep bothering you but I really need this fixed.
So, thanks again,

Kevin

Claps

Avatar: Claps

2006-11-10 20:16

roelofs88 - send a link to check it out.

roelofs88

No avatar

2006-11-11 13:59

www.motordelen.nl then click the contact page

roelofs88

No avatar

2006-11-11 14:00

It doesn't say much, just that there was an error.

minimus

No avatar

2006-11-11 17:22

Maybe it can be helpful for anyone having problems in emailing from quickcart:
please try to change 'FROM: ' into 'From: ' ( function mail(...) in sendOrderStatusToClient, sendOrderToClient ), it solved email header problems in my case (no any error but emails did not arrive to some accounts).

roelofs88

No avatar

2006-11-12 13:59

It's about the normal contact page, not the email that gets send to the Client when he or she places an order. This might work but where do I insert this code? in other.php? and what code do I use?

Claps

Avatar: Claps

2006-11-13 08:13

roelofs88 - wow, QC 0.3.0 ?!?!
in core/others.php try to replace function sendEmail() with:

function sendEmail( $aForm, $sFile = 'contact_send.tpl', $sTargetEmail = null ){
global $oCheckForm, $tpl, $headers;
extract( $aForm );

if( checkLength( $sTopic, 2 ) === true && checkLength( $sMailContent, 2 ) === true && checkEmail( $sSender ) === true ){
$sMailContent = changePolishToIso( $sMailContent );
$sTopic = changePolishToIso( $sTopic );

if( !isset( $sTargetEmail ) )
$sTargetEmail = EMAIL;

$headers = "From: Client <".$sSender.">\n";

if( @mail( $sTargetEmail, $sTopic, $sMailContent,$headers) ){
$content = $tpl->tbHtml( $sFile, 'SEND_GOOD' );
}
else
$content = $tpl->tbHtml( $sFile, 'SEND_ALERT' );
}
else
$content = $tpl->tbHtml( $sFile, 'WRONG_WORD' );
return $content;
} // end function sendEmail
}

.

roelofs88

No avatar

2006-11-14 19:21

It's still not working, does anyone else have a suggestion?

roelofs88

No avatar

2006-11-14 23:04

It's fixed!!
Someone helped me and it worked.
This is what I did.


$headers 
"From: mail@motordelen.nl \n";
$headers .= "Reply-to: ".$sSender."\n";



Instead of


$headers 
"From: Client <".$sSender.">\n";



Anyway, Thanks for all your help Claps.

Cu,

Kevin

vik

Avatar: vik

2006-12-08 20:00

I have to insert utf-8 coding for the function send email in the contact form.

I hope someone can help me,
thanks very much.

vik

Back to top
about us | contact