Mailform send to other domain

General questions about CMSimple
Post Reply
Nicky
Posts: 109
Joined: Sun Feb 08, 2009 9:50 am

Mailform send to other domain

Post by Nicky » Fri Aug 16, 2013 7:02 am

If i set a gmail address in my mailform (via configuration) this does not arrive because (according to my hosting provider) it is not sent to 'own domain'.

They (host) tell me to put 'headers' in the form, specifying the gmailaddress as destination.

I suppose this has to be done in 'mailform.php', but I have no idea which code exactly to add (and where) in this file.

Maybe someone can help out?
Thanks in advance.

Nicky
Posts: 109
Joined: Sun Feb 08, 2009 9:50 am

Re: Mailform send to other domain

Post by Nicky » Fri Aug 16, 2013 7:05 am

This is the code:

Code: Select all

<?php
/*
CMSimple_XH 1.1_i01
2010-01-03
For changelog, downloads and information please see http://www.cmsimple-xh.de
======================================
-- COPYRIGHT INFORMATION START --
based on CMSimple version 3.3 - December 31. 2009
Small - simple - smart
© 1999-2009 Peter Andreas Harteg - peter@harteg.dk
-- COPYRIGHT INFORMATION END --

This file is part of CMSimple
For licence see notice in /cmsimple/cms.php and http://www.cmsimple.org/?Licence
======================================
History:
2009-09-18  GE for CMSimple_XH
2008-11-19  JB for 32SE added captcha, senders phone and name
*/

if (eregi('mailform.php', sv('PHP_SELF')))die('Access Denied');

$title = $tx['title'][$f];
$o .= '<h1>'.$title.'</h1>';
initvar('sendername');
initvar('senderphone');
initvar('sender');
initvar('getlast');
initvar('cap');
initvar('mailform');

$t = '';

if ($action == 'send') {
$msg = ($tx['mailform']['sendername'] .": " .  stsl($sendername) . "\n" .  $tx['mailform']['senderphone'] .": ".  stsl($senderphone) . "\n\n"  . stsl($mailform));

// echo ($msg);
    if ($getlast !=$cap)  {
    $e .= '<li style="font-size: 118%;">'.$tx['mailform']['notaccepted'] ;
    }
    else  if ($mailform == '')  {
    $e .= '<li>'.$tx['error']['mustwritemes'];
    }
    else if(!(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[_a-z0-9-]+(\.[_a-z0-9-]+)*(\.([a-z]{2,4}))+$", $sender)))$e .= '<li>'.$tx['mailform']['notaccepted'];
    else if(!(@mail($cf['mailform']['email'], 'Mailform from '.sv('SERVER_NAME'), $msg, "From: ".stsl($sender)."\r\n"."X-Remote: ".sv('REMOTE_ADDR')."\r\n"))) 
    {
    $e .= '<li style="font-size: 118%;">'.$tx['mailform']['notsend'];
    }
    else $t = '<p style="font-size: 118%; text-align: center;">'.$tx['mailform']['send'].'</p>';
}

if ($t == '' || $e != '') {
//    if (@$tx['mailform']['message'] != '')$o .= '<p>'.$tx['mailform']['message'].'</p>';

// JB+ add captcha
    srand((double)microtime()*1000000);
    $random=rand(10000,99999);

    $o .= '<form action="'.$sn.'" method="post">';

    $o .=tag('input type="hidden" name="function" value="mailform"')
    .tag('input type="hidden" name="getlast" value="'.$random.'"')
    .tag('input type="hidden" name="action" value="send"')

// fields before textarea 
    .'<div style="width:200px; margin: 0 0 8px 0;">'.$tx['mailform']['sendername'].': '
    .tag('input type="text" class="text" size="35" name="sendername" value="'.htmlspecialchars(stripslashes($sendername)).'"')
    .'</div>'
    .'<div style="width:200px; margin: 0 0 8px 0;">'.$tx['mailform']['senderphone'].': '
    .tag('input type="text" class="text"  size="35"name="senderphone" value="'.htmlspecialchars(stripslashes($senderphone)).'"').'</div>'

    .'<div style="width:200px; margin: 0 0 20px 0;">'.$tx['mailform']['sender'].': '.tag('input type="text" class="text"  size="35" name="sender" value="'.htmlspecialchars(stripslashes($sender)).'"').'</div>';

// textarea
    $o.='<textarea style="border-color:#6a6a6a !important; border-width:1px;" rows="12" cols="40" name="mailform">';
    if ($mailform != 'true')$o .= htmlspecialchars(stsl($mailform));
    $o .= '</textarea>';

// captcha
    $o.='<div class="captcha" style="margin: 10px 0;">'.tag('input style="float:left" type="text" name="cap" class="captchainput" maxlength="5"').'<div style="float:left; color: #FFFFFF; text-decoration: none; background-color: #000000; padding: 0 5px; margin: 0px 4px;">
    '.$random.'</div><div style="float:left; margin-left:5px; margin-top:2px;">'. $tx['mailform']['captcha'] .'</div></div>';

// sendbutton
    $o.='<div style="clear:both; padding: 8px 0;">'.tag('input type="submit" class="submit" value="'.$tx['mailform']['sendbutton'].'"').'</div>';
    $o.='</form>';

}
else $o .= $t;

?>
Last edited by cmb on Fri Aug 16, 2013 10:00 am, edited 1 time in total.
Reason: marked up code as code

cmb
Posts: 12719
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Mailform send to other domain

Post by cmb » Fri Aug 16, 2013 10:21 am

Hi Nicky,
Nicky wrote:They (host) tell me to put 'headers' in the form, specifying the gmailaddress as destination.
Probably they meant to put appropriate headers in the mail. However, I believe there's a misunderstanding, as the destination address shouldn't matter, but the mail server might indeed block undesired senders. As it's now, the configured address is added as receiver (To) and the email address given in the form as sender (From). This happens in the following line:

Code: Select all

else if(!(@mail($cf['mailform']['email'], 'Mailform from '.sv('SERVER_NAME'), $msg, "From: ".stsl($sender)."\r\n"."X-Remote: ".sv('REMOTE_ADDR')."\r\n")))
You may try to change it like that:

Code: Select all

else if(!(@mail($cf['mailform']['email'], 'Mailform from '.sv('SERVER_NAME'), $msg, "From: ".$cf['mailform']['email']."\r\n"."X-Remote: ".sv('REMOTE_ADDR')."\r\n")))
To be able to see the sender's email address you have to modify the following line:

Code: Select all

$msg = ($tx['mailform']['sendername'] .": " .  stsl($sendername) . "\n" .  $tx['mailform']['senderphone'] .": ".  stsl($senderphone) . "\n\n"  . stsl($mailform));
Change it to:

Code: Select all

$msg = 'From: ' . stsl($sender) . "\n" . '($tx['mailform']['sendername'] .": " .  stsl($sendername) . "\n" .  $tx['mailform']['senderphone'] .": ".  stsl($senderphone) . "\n\n"  . stsl($mailform));
BTW: you should really update to at least CMSimple_XH 1.1.7 as soon as possible (it will be published in the next days or weeks). The old mailform code has several issues, which might affect sending mails on your domain.

Christoph
Christoph M. Becker –Plugins for CMSimple_XH, but not for CMSimple 4+

Post Reply