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
https://forums.phpfreaks.com/topic/100840-solved-php-mail-and-hotmail/
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: [email protected]' . "\r\n";
	$additional_parameters = "-f [email protected]";
	mail($to, $subject, $body, $headers, $additional_parameters);

 

Any help is greatly appreciated.

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: [email protected]' . "\r\n";


$headers.= "-f [email protected]";


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

 

<?php
$headers  = 'From: ' . $from . "\n";
$headers .= 'To: ' . $email . "\n";
$headers .= 'Return-Path: ' . [email protected]. "\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";
?>

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

 

<?php
$from = "[email protected]";
$to = "[email protected]";

$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: ' . "[email protected]" . "\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!

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);?>

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 = "[email protected]";
$to_name = "[email protected]";
$to_email = "[email protected]";
$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.

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.

try

<?php
$boundary="_----------=_10167391557129230";
$from_name = "Support";
$from_email = "[email protected]";
$to_name = "[email protected]";
$to_email = "[email protected]";
$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);
?>

Modified Final:

 

<?php

$from_name = "Support";
$from_email = "[email protected]";
$to_name = "[email protected]";
$to_email = "[email protected]";
$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!";}
?>

noticed an error in my coding:

 

 

<?php
$from_name = "Support";
$from_email = "[email protected]";
$to_name = "[email protected]";
$to_email = "[email protected]";
$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!";}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.