MyBB Community Forums

Full Version: Email Verification
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I just finished setting up all the php mail settings, and now some users can't receive the verification emails. I've tried to get a verification email to Hotmail and Sympatico, and couldn't, but I could recieve it in Gmail. Is there any way to fix this, so that every new member gets a registration email?

I'm using MyBB version 1.1.5 and I found this thread where a user had trouble with Yahoo accounts. I'm not sure if it's the same problem or not, but Tikitiki's reply confused me.

Any help?
Have users checked their junk mail and trash folders to ensure it is not being delivered there?

You say it delivered fine to Gmail - well, nothing in MyBB stops it being delivered to Hotmail or Sympatico accounts.

If you've configured your mail server youself, you should be able to view the mail server logs to check that mail is being sent out from the server and delivered to the recipients.
It's on a Windows Server, and I'm new to all of this, so I have no clue where my mail server logs are, if I have any. I'm using smtp1.sympatico.ca as my SMTP server. I have checked my junk folders on Hotmail and Sympatico, maybe it takes a long time? EDIT: probably not the long time part, because it's been about 2 hours since the original email.
Okay! I got it working! (I don't know if I did a crude job of it as I don't know PHP, but it's working)

Here's how I did it for anyone else who has problems, I guess. (Hopefully someone will correct any wrong code in here)

1. I went into inc/functions.php and found
//
// MyBB mail wrapper (soon to be a class)
//
function mymail($to, $subject, $message, $from="")
{
	global $db, $mybb, $settings;
	// For some reason sendmail/qmail doesn't like \r\n
	$sendmail = @ini_get('sendmail_path');
	if($sendmail)
	{
		$message = preg_replace("#(\r\n|\r|\n)#s", "\n", $message);
	}
	else
	{
		$message = preg_replace("#(\r\n|\r|\n)#s", "\r\n", $message);
	}
	if(strlen(trim($from)) == 0)
	{
		$from = "\"".$mybb->settings['bbname']." Mailer\" <".$mybb->settings['adminemail'].">";
	}

	mail($to, $subject, $message, "From: $from");
}
and then added headers and $headers to the mail() part, so it looked like this:
//
// MyBB mail wrapper (soon to be a class)
//
function mymail($to, $subject, $message, $from="")
{
	global $db, $mybb, $settings;
	// For some reason sendmail/qmail doesn't like \r\n
	$sendmail = @ini_get('sendmail_path');
	if($sendmail)
	{
		$message = preg_replace("#(\r\n|\r|\n)#s", "\n", $message);
	}
	else
	{
		$message = preg_replace("#(\r\n|\r|\n)#s", "\r\n", $message);
	}
	if(strlen(trim($from)) == 0)
	{
		$from = "\"".$mybb->settings['bbname']." Mailer\" <".$mybb->settings['adminemail'].">";
	}
	$headers .= "X-Priority: 1\n"; 
	$headers .= "X-MSMail-Priority: High\n"; 
	$headers .= "X-Mailer: My mailer"; 

	mail($to, $subject, $message, $headers, "From: $from");
}
EDIT: It now sends it to the junk email folder, but at least it got there.
You can try replacing the function with:
function mymail($to, $subject, $message, $from="", $charset="")
{
	global $db, $mybb, $lang;

	if($charset == "")
	{
		//$charset = "ISO-8859-1";
		$charset = $lang->settings['charset'];
	}

	if(function_exists('mb_language') && function_exists('mb_encode_mimeheader'))
	{
		mb_language($lang->settings['htmllang']);
  		$subject = str_replace('ISO-8859-1', $charset, mb_encode_mimeheader($subject));
 		$from = str_replace('ISO-8859-1', $charset, mb_encode_mimeheader($from));
	}

	// Build mail headers
	if(my_strlen(trim($from)) == 0)
	{
		$from = "\"".$mybb->settings['bbname']." Mailer\" <".$mybb->settings['adminemail'].">";
	}
	$headers = "From: {$from}\n";
	$headers .= "Return-Path: {$mybb->settings['adminemail']}\n";
	if($_SERVER['SERVER_NAME'])
	{
		$http_host = $_SERVER['SERVER_NAME'];
	}
	else if($_SERVER['HTTP_HOST'])
	{
		$http_host = $_SERVER['HTTP_HOST'];
	}
	else
	{
		$http_host = "unknown.local";
	}
	$headers .= "Message-ID: <". md5(uniqid(time()))."@{$http_host}>\n";
	$headers .= "MIME-Version: 1.0\n";
	$headers .= "Content-Type: text/plain; charset=\"{$charset}\"\n";
	$headers .= "Content-Transfer-Encoding: 8bit\n";
	$headers .= "X-Priority: 3\n";
	$headers .= "X-MSMail-Priority: Normal\n";
	$headers .= "X-Mailer: MyBB\n";

	// For some reason sendmail/qmail doesn't like \r\n
	$sendmail = @ini_get('sendmail_path');
	if($sendmail)
	{
		$headers = preg_replace("#(\r\n|\r|\n)#s", "\n", $headers);
		$message = preg_replace("#(\r\n|\r|\n)#s", "\n", $message);
	}
	else
	{
		$headers = preg_replace("#(\r\n|\r|\n)#s", "\r\n", $headers);
		$message = preg_replace("#(\r\n|\r|\n)#s", "\r\n", $message);
	}

	mail($to, $subject, $message, $headers);
}

That is directly from 1.2 and contaisn the X-Priority and X-MSMail-Priority headers (set at normal however).
thanks!