Jump to content

[SOLVED] PHP Mail and Hotmail


raku

Recommended Posts

Hi,

 

When users create an account on my site, they are required to activate it by clicking a link in an email they receive. All emails seem to be getting delivered successfully except those to Hotmail. I assume that it's being sent directly to their Junk folder. Is there anyway around this?

 

Thanks!

Link to comment
Share on other sites

I got this working by using the following headers:

 

$headers = 
"MIME-Version: 1.0\r\n" .
"Content-type: text/plain; charset=utf-8\r\n" .
"From: support@voteoften.us\r\n" .	
"X-Mailer: php" .phpversion() . "\r\n";

 

 

Link to comment
Share on other sites

Actually, the email does not display properly with GMail anymore. It says (unknown sender) and shows the following in the body of the email:

 

Content-type: text/plain; charset=utf-8

From: support@domain.com
X-Mailer: php5.1.6

 

 

 

Link to comment
Share on other sites

Here is the PHP code I have. Right now it's going into Yahoo and Hotmail's spam folders, but it works for GMail.

 

	$to = $email;
	$subject = 'Activate Account';
	$body =  'Click the link below to activate your account' . "\r\n";
	$headers = 
		'From: support@domain.com' . "\r\n";
	$additional_parameters = "-f support@domain.com";
	mail($to, $subject, $body, $headers, $additional_parameters);

 

Any help is greatly appreciated.

Link to comment
Share on other sites

PHP mail only accecpts 4 arguments put additional whatever into the headers like

 

Also modified it with /r/n so it recognized the mail and doesnt hopefully throw it in the junk folder ;D

 

<?php
$to = $email;
	$subject = 'Activate Account' . "\r\n";
	$body =  'Click the link below to activate your account' . "\r\n";
	$headers = 
		'From: support@domain.com' . "\r\n";


$headers.= "-f support@domain.com";


mail($to, $subject, $body, $headers);
?>

 

Link to comment
Share on other sites

Thanks for your help. Unfortunately, Hotmail still throws it into the Junk folder. Going to try Yahoo now.

 

edit: Yahoo goes to Spam.  :-[

 

edit 2: the body of the email also contains "-f support@domain.com"

Link to comment
Share on other sites

<?php
$headers  = 'From: ' . $from . "\n";
$headers .= 'To: ' . $email . "\n";
$headers .= 'Return-Path: ' . support@domain.com. "\n";
$headers .= 'MIME-Version: 1.0' ."\n";
$headers .= 'Content-Type: text/plain; charset=ISO-8859-1' ."\n";
$headers .= 'Content-Transfer-Encoding: 8bit'. "\n\n";
$headers .= 'Content-Type: text/HTML; charset=ISO-8859-1' ."\n";
$headers .= 'Content-Transfer-Encoding: 8bit'. "\n\n";
$headers .= $body. "\n";
?>

Link to comment
Share on other sites

Thanks again. But it's still going to spam. This is the code I'm using:

 

<?php
$from = "support@domain.com";
$to = "email@email.com";

$subject = 'Activate Account' . "\r\n";
$body =  'Click the link below to activate your account' . "\r\n";

$headers  = 'From: ' . $from . "\n";
$headers .= 'To: ' . $to . "\n";
$headers .= 'Return-Path: ' . "support@domain.com" . "\n";
$headers .= 'MIME-Version: 1.0' ."\n";
$headers .= 'Content-Type: text/plain; charset=ISO-8859-1' ."\n";
$headers .= 'Content-Transfer-Encoding: 8bit'. "\n\n";
$headers .= $body. "\n";

mail($to, $subject, $body, $headers);
?>

 

Should body be in the header?

 

Thanks!

Link to comment
Share on other sites

here is the full code if you want to modify it

 

<?php
$boundary = api_password(16);
$headers = "From: \"".$from_name."\" <".$from_email.">\n"; $headers .=
"To: \"".$to_name."\" <".$to_email.">\n"; $headers .= "Return-Path:
<".$from_email.">\n"; $headers .= "MIME-Version: 1.0\n"; $headers .=
"Content-Type: multipart/alternative; boundary=\"".$boundary."\"\n\n";
$headers .= $body_simple."\n"; $headers .= "--".$boundary."\n"; $headers
..= "Content-Type: text/plain; charset=ISO-8859-1\n"; $headers .=
"Content-Transfer-Encoding: 8bit\n\n"; $headers .= $body_plain."\n";
$headers .= "--".$boundary."\n"; $headers .= "Content-Type: text/HTML;
charset=ISO-8859-1\n"; $headers .= "Content-Transfer-Encoding:
8bit\n\n"; $headers .= $body_html."\n"; $headers .=
"--".$boundary."--\n";

mail('', $subject, '', $headers);?>

Link to comment
Share on other sites

Hi,

 

I guess I have to remove the html and plain code since I'm using simple text. This is what I have, but it still goes to spam:

 

<?php
$boundary="_----------=_10167391557129230";
$from_name = "Support";
$from_email = "support@domain.com";
$to_name = "mail@yahoo.com";
$to_email = "mail@yahoo.com";
$body_simple = "Click the link below to activate your account";

$headers = "From: \"".$from_name."\" <".$from_email.">\n";
$headers .= "To: \"".$to_name."\" <".$to_email.">\n";$headers .= "Return-Path:
<".$from_email.">\n"; $headers .= "MIME-Version: 1.0\n"; $headers .=
"Content-Type: multipart/alternative; boundary=\"".$boundary."\"\n\n";
$headers .= $body_simple."\n"; $headers .= "--".$boundary."\n"; $headers .= "--".$boundary."--\n";

mail('', $subject, '', $headers);
?>

 

Also, what does boundary do?

 

Thanks for your help.

Link to comment
Share on other sites

I'm having trouble finding documentation for that, could you please point me in the right direction? The email I received on a Yahoo account also contained some of the headers and was in spam. Is this because of the boundaries as well, or something else?

 

Sorry, but I'm in a bit of a rush to get these emails out of the spam/junk folders.

 

Thanks.

Link to comment
Share on other sites

try

<?php
$boundary="_----------=_10167391557129230";
$from_name = "Support";
$from_email = "support@domain.com";
$to_name = "mail@yahoo.com";
$to_email = "mail@yahoo.com";
$body_simple = "Click the link below to activate your account";
$headers = "$from_email<$from_email>";
$headers .= "$to_email<$to_email>"; 
$headers .= "MIME-Version: 1.0\n"; 
$headers .=
"Content-Type: multipart/alternative; boundary=\"".$boundary."\"\n\n";
$headers .= $body_simple."\n"; $headers .= "--".$boundary."\n"; 
$headers .= "--".$boundary."--\n";

mail('', $subject, '', $headers);
?>

Link to comment
Share on other sites

Modified Final:

 

<?php

$from_name = "Support";
$from_email = "support@domain.com";
$to_name = "mail@yahoo.com";
$to_email = "mail@yahoo.com";
$subject = "Click the link below to activate your account";
$headers = "$from_name<$from_email>";
$headers .= "$to_email<$to_email>"; 
$headers .= "MIME-Version: 1.0\n"; 

$mail=mail($to_name, $subject, $message, $headers);

if($mail) { echo "Message Was Successfuly Sent!";}

else { echo "Message could not be sent!";}
?>

Link to comment
Share on other sites

Unfortunately, it still goes to spam. It was also sending it as user@domain.com, so I added "From:" and "To:" in the headers. That made it send it twice, but the from email address is correct. I think the "To:" caused it to be sent twice.

Link to comment
Share on other sites

noticed an error in my coding:

 

 

<?php
$from_name = "Support";
$from_email = "support@domain.com";
$to_name = "mail@yahoo.com";
$to_email = "mail@yahoo.com";
$subject = "Click the link below to activate your account";
$headers = "$from_name<$from_email>\n";
$headers .= "$to_email<$to_email>\n"; 
$headers .= "MIME-Version: 1.0\n"; 
$headers .= "Reply-To: $to_name <$to_email>\n"; 
$headers .= "X-Priority: 1\n"; 
$headers .= "X-MSmail-Priority: High\n"; 
$headers .= "X-mailer: My mailer\n";
$mail=mail($to_email, $subject, $message, $headers);

if($mail) { echo "Message Was Successfuly Sent!";}
else { echo "Message could not be sent!";}
?>

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.