Page 1 of 1

Website Email Address

Posted: Thu Jul 23, 2009 6:07 pm
by duxbox
Hello everyone,

Lets say, every time my website sends out an automated email notification to the members, these emails appear as eg. info@mysite.com in their email inbox email list.

This is actually before you click on the email to open it. I tested it in Yahoo! and Hotmail and both show info@mysite.com, but Gmail is even worst, it takes the first part of the email and only shows info when previewing your emails. instead of the plain email address or just showing the word "info" like the case in Gmail.

This is more a cosmetic thing but I would like it to work like any other professional website by simply showing eg. MY SITE <info@sitename.com>, this way when people receive an email from my website, they can see MY SITE in their email preview list.

Checking my config.inc.php I see the following related lines for FROM EMAIL:

Code: Select all

 
 
// Name of the site
$site_name = "MY SITE";
 
// Site email address
$site_email = "info@mysite.com";
 
// From address to use for mails sent using the contact form.
// Set to $site_email to make it the same as the site email set above.
$contactmail_from = $site_email;
 
 
I am not a programmer but I would assume this is done here at the config.inc.php file.
I tried replacing the site email to:

Code: Select all

$site_email = "SITE NAME <info@mysite.com>";
and the emails are now showing correctly in email previews, but now I am getting duplicated email in my info@mysite.com email for every email that is sent to users.

Any idea how this is done?

I appreciate your feedback and comments in advance.

Re: Website Email Address

Posted: Thu Jul 23, 2009 7:05 pm
by requinix
You can't just blindly change values in configuration files without knowing what it is you're changing. What if the code expects $site_email to be exactly an email address? You might get unusual behavior - such as receiving a copy of mail sent.

What system are you toying with? Where's the person who's supposed to be maintaining this code?

Re: Website Email Address

Posted: Sat Jul 25, 2009 2:41 am
by cpetercarter
Don't alter $site_email, as this may be used for other purposes in the programme. Instead, alter $contactmail_from to read something like:

Code: Select all

$contactmail_from = "my_site_name@mysite.com";
Obviously, replace "my_site_name" with your actual site name; and remember that you cannot put spaces in e-mail addresses - you need to use underscores or periods.

Re: Website Email Address

Posted: Sat Jul 25, 2009 8:23 am
by Eric!
Like tasairis says, without knowing how these variables are used, you are probably going to create more problems for yourself.

That said, you could try adding your plain text field into
$contactmail_from = "MY SITE <my_site_name@mysite.com>";

But it probably won't work either without knowing exactly what and how $contactmail_from is used in the code.

Re: Website Email Address

Posted: Sat Jul 25, 2009 11:53 pm
by duxbox
Thanks for all your responses,

I went ahead and changed the $contacmail_from to the following:

Code: Select all

$contactmail_from = "MY SITE <my_site_name@mysite.com>";
and now when people are using the form in my pages, I get the emails correctly as I wanted. It shows in the email header SITE NAME <site_email@domain.com> which is really cool. I tested it a few times and I am not getting any duplicated email like the previous case when I changed the $site_email=

Now, my script does send out an activation email to users when they first post a message in the website and the message doesn't appear until they actually click on an activation link that is send to them via email. This activation link is still being send out as a plain email address.

Here is the mail( ) portion part of the POST.PHP file:

Code: Select all

           $subj = $lang['MAILSUBJECT_NEW_POST'];
            $subj = str_replace("{@ADTITLE}", $data['adtitle'], $subj);
         if (!@xmail($_POST['email'], $subj, $msg, $site_email, $langx['charset']))
is there any way to simply insert $site_name somewhere in there to get: SITE NAME <site_email@domain.com> for the activation emails as well?

Thanks guys,

Re: Website Email Address

Posted: Sun Jul 26, 2009 9:01 am
by Eric!
I guess you got lucky it worked.

What is xmail()? I'm not familar with that. Whatever it is, it looks insecure because it is taking the $_POST data directly. Hopefully there are some user input filters burried in xmail somewhere.

Anyway is your problem you don't want $site_email passed to xmail but prefer $contactmail_from?

Do you see a standard mail() call in post.php anywhere?

Re: Website Email Address

Posted: Mon Jul 27, 2009 11:34 pm
by duxbox
This is the mail code from another page called showad.php that has a form and sends the emails with full header like MY SITE <myemail@domain.com> which I am trying to replicate for the activation emails.


Code: Select all

        // Makeup mail headers and compose mime msg
        
        $mime_boundary = "<<<-=-=-[xzero.clfx.".md5(time())."]-=-=->>>";
 
        $mailheaders  = "";
        $mailheaders .= "From: $contactmail_from\n";
        $mailheaders .= "Reply-To: $_POST[email]\n";
        $mailheaders .= "Date: " . date("r") . "\n";
        $mailheaders .= "Message-ID: " . generateMessageID() . "\n";
 
        if($_FILES['attach']['tmp_name'] && !$_FILES['attach']['error'])
        {
            $filename = $_FILES['attach']['name'];
            $filetmpname = $_FILES['attach']['tmp_name'];
            $filesize = $_FILES['attach']['size'];
            $filecontents = base64_encode(file_get_contents($filetmpname));
            $fileencoding = "base64";
 
            $dotpos = strrpos($filename, ".");
            if($dotpos !== FALSE) $ext = substr($filename, -$dotpos+1);
 
            if (in_array($ext, $contactmail_attach_wrongfiles))
            {
                $mailerr = $lang['ERROR_INVALID_ATTACHMENT'];
            }
            elseif($filesize > $contactmail_attach_maxsize*1000)
            {
                $mailerr = "The attachment is too big";
            }
            else
            {
                $mailheaders .= "MIME-Version: 1.0\n";
                $mailheaders .= "Content-Type: multipart/mixed;\n";
                $mailheaders .= " boundary=\"".$mime_boundary."\"";
 
                $fullmsg  = "";
                $fullmsg .= "This is a multi-part message in MIME format.\n";
                $fullmsg .= "\r\n";
                $fullmsg .= "--".$mime_boundary."\r\n";
 
                $fullmsg .= "Content-Type: text/plain; charset=\"{$langx[charset]}\"\n";
                $fullmsg .= "Content-Transfer-Encoding: 8bit\n";
                $fullmsg .= "\r\n";
                $fullmsg .= $mail;
                $fullmsg .= "\r\n";
                $fullmsg .= "--".$mime_boundary."\r\n";
 
                $fullmsg .= "Content-Type: application/octet-stream; name=\"".$filename."\"\n";
                $fullmsg .= "Content-Transfer-Encoding: ".$fileencoding."\n";
                $fullmsg .= "Content-Disposition: attachment; filename=\"".$filename."\"\n";
                $fullmsg .= "\r\n";
                $fullmsg .= $filecontents;
                $fullmsg .= "\r\n";
                $fullmsg .= "--".$mime_boundary."--\r\n";
            }
        }
        else
        {
            $mailheaders .= "Content-Type: text/plain; charset=\"{$langx[charset]}\"\n";
            $mailheaders .= "Content-Transfer-Encoding: 8bit\n";
            $fullmsg = $mail;
        }
 
        $mailheaders .= "\r\n";
 
        if ($mailerr)
        {
            $mailresult = "n";
        }
        else
        {
            if (mail($ad['email'], $lang['MAILSUBJECT_CONTACT_FORM'], $fullmsg, $mailheaders, "-f{$site_email}"))
                $mailresult = "y";
            else
                $mailresult = "n";
        }
 
        header("Location: $script_url/?$qs&mailed=$mailresult&mailerr=$mailerr");
        exit;


the page that I am working on which sends an activation link for each message or ad that users post on the site is called post.php and has the following email code:

Code: Select all

           $subj = $lang['MAILSUBJECT_NEW_POST'];
            $subj = str_replace("{@ADTITLE}", $data['adtitle'], $subj);
            if (!@xmail($_POST['email'], $subj, $msg, $site_email, $langx['charset']))

Any idea?

Thanks,