I know this is weird, but when a ".com" is added to the subject or body text to send PHP mail (like - xyz.com), the mail will not send. It's a problem with this hosting company (ipage) but i want to see if their is something i can do in the script itself, because it's a CMS of mines and i would like to keep generalized for everyone who uses it.
script is simple and as follows:
function confirmEmail($username, $email, $confirm_code) {
$sitename = str_replace(".com", " .com", site_name);
$subject = "Your confirmation link here";
$headers .= 'To: '.$username.' <'.$email.'>' . "\r\n";
$headers .= "From: ".$sitename." <".support_email.">". "\r\n";
$message = "Your Comfirmation link \n
Click on this link to activate your 开发者_开发技巧account \n
".root."/confirm.php?confirm=$confirm_code";
$message = wordwrap($message, 70);
$sendmail = mail($username,$subject,$message,$headers);
if ( $sendmail ) {
return true;
} else {
return false;
}
}
Now as you can see, i replace the ".com" with " .com"(note the space at the beginning) for the $sitename variable, and that works but the problem is the "root" contains the full path to the givin site so the link is like "xyz.com/confirm.php?confirm=$confirm_code". I can't allow a space before the '.com' in the site path like "xyz .com/etc..." because the obviously the user can't click the link from within their email.
I know this is a weird problem and I have no clue on what's going on or what to even ask the hosting to change.
*note: site_name and root are defined previously in another page, and they work fine. Also no errors are being returned.
Any ideas out there?
Your code is correct. Your workaround should not be necessary.
This is very likely a provider issue.
Don't know about your environment, but if you have not full control of your mailserver, try sending a mail with a link using telnet so you really see everything. Often spam filters etc are badly configured and don't return the correct codes.
If you don't have any luck with that I recommend switching to an external SMTP server that is well configured. You can perfectly use gmail for that if you dont send tons of mails.
精彩评论