Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

Strange problem!

the mail() function

Moderators: macek, egami, gesf

Strange problem!

Postby kkanzel1 » Tue Apr 12, 2011 11:42 am

I'm using an email validation code to verify user accounts, and I'm getting some strange behavior. The following is the code:

// send e-mail to ...
$to=$email;

// Your subject
$subject="Your confirmation link here";

// From
$header="from: ECE Projects <webmaster@eceprojects.co.cc>";

// Your message
$message="Click the link to activate your account. \n\r";
$message.="http://www.eceprojects.co.cc/userPages/confirmation.php?passkey=$confirm_code";

// send email
$sentmail = mail($to,$subject,$message,$header);

The problem lies in the link. My website is http://www.eceprojects.co.cc. When i use the full url, the email is never sent. However, if I delete one of the domain extensions ".co" or ".cc" it sends an email with no problem. So the problem seems to be using ".co.cc". For some reason this creates an error. Any thoughts?
Last edited by kkanzel1 on Tue Apr 12, 2011 5:50 pm, edited 1 time in total.
kkanzel1
New php-forum User
New php-forum User
 
Posts: 6
Joined: Tue Apr 12, 2011 11:32 am

Re: Strange syntax problem??

Postby egami » Tue Apr 12, 2011 11:56 am

try wrapping quotes around mail($to,$subject,"$message",$headers);
User avatar
egami
php-forum GURU
php-forum GURU
 
Posts: 2196
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Re: Strange syntax problem??

Postby kkanzel1 » Tue Apr 12, 2011 12:47 pm

Thanks for the reply, still no dice though. Any other thoughts? Has anyone heard of anything like this before?

This is the tutorial I followed: http://www.phpeasystep.com/phptu/24.html. It works well with a single domain extension, but it doesn't work with both domain extensions.
kkanzel1
New php-forum User
New php-forum User
 
Posts: 6
Joined: Tue Apr 12, 2011 11:32 am

Re: Strange syntax problem??

Postby egami » Tue Apr 12, 2011 12:51 pm

Try sending the email as HTTP encoded.
Perhaps it's a client thing that's stripping the domain while trying to create a suedo link for it?
User avatar
egami
php-forum GURU
php-forum GURU
 
Posts: 2196
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Re: Strange syntax problem??

Postby Nullsig » Tue Apr 12, 2011 1:08 pm

its probably actually a problem with who ever handles your e-mail.

You may have that domain blacklisted. I would also try sending more than just the link in the e-mail because some e-mail providers won't send on e-mail addresses that just contain links.

I personally send lots of e-mails from php containing links both in html and plaintext formats.
User avatar
Nullsig
php-forum Fan User
php-forum Fan User
 
Posts: 981
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI

Re: Strange syntax problem??

Postby kkanzel1 » Tue Apr 12, 2011 3:14 pm

Keep in mind, the mail function works perfectly using a different url in the message (see red text).

for example, this works fine:
$message.="http://www.eceprojects.cc/userPages/confirmation.php?passkey=$confirm_code";


This doesn't send an email:
$message.="http://www.eceprojects.co.cc/userPages/confirmation.php?passkey=$confirm_code";

Look carefully, the only difference is the domain extension.

Any thoughts?
kkanzel1
New php-forum User
New php-forum User
 
Posts: 6
Joined: Tue Apr 12, 2011 11:32 am

Re: Strange syntax problem??

Postby kkanzel1 » Tue Apr 12, 2011 4:58 pm

****************** UPDATE ******************

Strange new observation: In the message link, if I reverse the order of the domains, the email is sent. If I use the correct order, the email is not sent.


i.e.:

http://www.eceprojects.cc.co Works fine, but is not the correct url.
http://www.eceprojects.co.cc Doesn't work, but is the correct url.

Any thoughts?
kkanzel1
New php-forum User
New php-forum User
 
Posts: 6
Joined: Tue Apr 12, 2011 11:32 am

Re: Strange problem!

Postby kkanzel1 » Tue Apr 12, 2011 5:53 pm

So the problem is definitely with the domain extension co.cc.

Does anyone know what is wrong with the domain? Do I need to adjust any settings (like Cname, MX, etc.)?
kkanzel1
New php-forum User
New php-forum User
 
Posts: 6
Joined: Tue Apr 12, 2011 11:32 am

Re: Strange problem!

Postby johnj » Tue Apr 12, 2011 10:16 pm

You may also try this:

$str = "cc";
$message.="http://www.eceprojects.co.".$str."/userPages/confirmation.php?passkey=$confirm_code";
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Strange problem!

Postby kkanzel1 » Wed Apr 13, 2011 10:33 am

Thanks for ideas. Still no luck though. I think it must be a domain thing. I've read about sites blocking domains "co.cc", so I wonder if, since my domain is "co.cc", the email provider (gmail, hotmail, etc) is blocking the email because the contents contain the domain extension "co.cc".

Any other thoughts??
kkanzel1
New php-forum User
New php-forum User
 
Posts: 6
Joined: Tue Apr 12, 2011 11:32 am

Re: Strange problem!

Postby egami » Wed Apr 13, 2011 12:00 pm

I find it very hard to believe that any sort of mail filter is going to filter a URL based upon content of an email. While I know it's not impossible, it's just very likely, improbable.

This worked fine for me..
Code: Select all

$email 
"stripped@nowhere.com";
$confirm_code '1234567890';

// send e-mail to ...
$to=$email;

// Your subject
$subject="Your confirmation link here";

// From
$header="from: ECE Projects <webmaster@eceprojects.co.cc>";

// Your message
$message="Click the link to activate your account. \n\r";
$message.="http://www.eceprojects.co.cc/userPages/confirmation.php?passkey=$confirm_code";

// send email
if ($sentmail mail($to,$subject,$message,$header)) {
    echo 
"Mail sent successfully<br />";
} else {
    echo 
"Something went wrong <br />";
}
 


Produced:

Click the link to activate your account.

http://www.eceprojects.co.cc/userPages/ ... 1234567890

Outlook 2007 automagically created a URL link for it.
User avatar
egami
php-forum GURU
php-forum GURU
 
Posts: 2196
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT


Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron