Jump to content

PHP MAIL simple request


Gayner

Recommended Posts

$host  = $_SERVER['HTTP_HOST'];
$host_upper = strtoupper($host);
$login_path = @ereg_replace('admin','',dirname($_SERVER['PHP_SELF']));
$path   = rtrim($login_path, '/\\');
$message = 
"Thank you for registering with us. Your account has been activated...

*****LOGIN LINK*****\n
http://$host$path/login.php

Thank You

Administrator
$host_upper
______________________________________________________
THIS IS AN AUTOMATED RESPONSE. 
***DO NOT RESPOND TO THIS EMAIL****
";

@mail($to_email, "User Activation", $message,
    "From: \"Member Registration\" <auto-reply@$host>\r\n" .
     "X-Mailer: PHP/" . phpversion());

 

ok so it works but when i get my message its like this:

2rhp83l.jpg

 

It says MAILED BY-CP02.Stablehost.com

I don't want to show MY SHARED HOSTING PROVIDEr.. LOL How do i FIX?

 

 

Link to comment
Share on other sites

Gmail and anything that can read e-mail headers would see where it is coming from. If your e-mail is physically coming from your shared host's server, than that is what it'll show. You can ask your host to create an alias (so it shows mail.yourdomain.com) or register for another mail service..

Link to comment
Share on other sites

Gmail and anything that can read e-mail headers would see where it is coming from. If your e-mail is physically coming from your shared host's server, than that is what it'll show. You can ask your host to create an alias (so it shows mail.yourdomain.com) or register for another mail service..

 

a Alias just for my account ?

Link to comment
Share on other sites

Gmail and anything that can read e-mail headers would see where it is coming from. If your e-mail is physically coming from your shared host's server, than that is what it'll show. You can ask your host to create an alias (so it shows mail.yourdomain.com) or register for another mail service..

 

a Alias just for my account ?

 

Ask them to set up an MX record for your domain, so you can 'send' messages from your smtp server.

Link to comment
Share on other sites

Here is a more verbose explanation -

 

Your hosting control panel should have a section called DNS zone record/editor... You need to create an A record for your domain, something like mail.yourdomain.com that points to the IP address of your host's actual mail server. You then need to create an MX record that points to mail.yourdomain.com This will make it appear that you have a mail server by the name mail.yourdomain.com You then send mail from your php script using mail.yourdomain.com as the SMTP hostname setting (use an ini_set() statement in your script.)

 

This should cause mail sent by your script to appear as though it is coming from your 'own' mail server.

Link to comment
Share on other sites

use optional 5th sendmail parameter:

 

<?php
$headers  = "From: Member Registration <auto-reply@{$host}\r\n";
$headers .= "X-Mailer: PHP " . phpversion() . "\r\n";

if (mail($to_email, "User Activation", $message, $headers, "-fauto-reply@{$host}"))
{
     echo 'Message Sent!';
}
else
{
     echo 'Message Not Sent.';
}
?>

 

code assumes $host is a trusted domain on the server.

 

do not suppress mail function .. simply handle it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.