raku Posted April 12, 2008 Share Posted April 12, 2008 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 More sharing options...
raku Posted April 12, 2008 Author Share Posted April 12, 2008 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: [email protected]\r\n" . "X-Mailer: php" .phpversion() . "\r\n"; Link to comment https://forums.phpfreaks.com/topic/100840-solved-php-mail-and-hotmail/#findComment-515735 Share on other sites More sharing options...
raku Posted April 12, 2008 Author Share Posted April 12, 2008 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: [email protected] X-Mailer: php5.1.6 Link to comment https://forums.phpfreaks.com/topic/100840-solved-php-mail-and-hotmail/#findComment-515737 Share on other sites More sharing options...
raku Posted April 12, 2008 Author Share Posted April 12, 2008 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. Link to comment https://forums.phpfreaks.com/topic/100840-solved-php-mail-and-hotmail/#findComment-515747 Share on other sites More sharing options...
raku Posted April 13, 2008 Author Share Posted April 13, 2008 Anyone know how to fix this? Thanks! Link to comment https://forums.phpfreaks.com/topic/100840-solved-php-mail-and-hotmail/#findComment-515827 Share on other sites More sharing options...
darkfreaks Posted April 13, 2008 Share Posted April 13, 2008 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 <?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); ?> Link to comment https://forums.phpfreaks.com/topic/100840-solved-php-mail-and-hotmail/#findComment-515830 Share on other sites More sharing options...
raku Posted April 13, 2008 Author Share Posted April 13, 2008 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 [email protected]" Link to comment https://forums.phpfreaks.com/topic/100840-solved-php-mail-and-hotmail/#findComment-515839 Share on other sites More sharing options...
darkfreaks Posted April 13, 2008 Share Posted April 13, 2008 <?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"; ?> Link to comment https://forums.phpfreaks.com/topic/100840-solved-php-mail-and-hotmail/#findComment-515841 Share on other sites More sharing options...
raku Posted April 13, 2008 Author Share Posted April 13, 2008 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! Link to comment https://forums.phpfreaks.com/topic/100840-solved-php-mail-and-hotmail/#findComment-515847 Share on other sites More sharing options...
darkfreaks Posted April 13, 2008 Share Posted April 13, 2008 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 https://forums.phpfreaks.com/topic/100840-solved-php-mail-and-hotmail/#findComment-515851 Share on other sites More sharing options...
darkfreaks Posted April 13, 2008 Share Posted April 13, 2008 also instead of api_pasword you could do <?php $boundary="_----------=_10167391557129230";?> Link to comment https://forums.phpfreaks.com/topic/100840-solved-php-mail-and-hotmail/#findComment-515853 Share on other sites More sharing options...
raku Posted April 13, 2008 Author Share Posted April 13, 2008 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. Link to comment https://forums.phpfreaks.com/topic/100840-solved-php-mail-and-hotmail/#findComment-515858 Share on other sites More sharing options...
darkfreaks Posted April 13, 2008 Share Posted April 13, 2008 Read up on MIME boundaries Link to comment https://forums.phpfreaks.com/topic/100840-solved-php-mail-and-hotmail/#findComment-515862 Share on other sites More sharing options...
raku Posted April 13, 2008 Author Share Posted April 13, 2008 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 https://forums.phpfreaks.com/topic/100840-solved-php-mail-and-hotmail/#findComment-515881 Share on other sites More sharing options...
darkfreaks Posted April 13, 2008 Share Posted April 13, 2008 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); ?> Link to comment https://forums.phpfreaks.com/topic/100840-solved-php-mail-and-hotmail/#findComment-515889 Share on other sites More sharing options...
raku Posted April 13, 2008 Author Share Posted April 13, 2008 Thanks so much for helping. No email is delivered though. Link to comment https://forums.phpfreaks.com/topic/100840-solved-php-mail-and-hotmail/#findComment-515895 Share on other sites More sharing options...
darkfreaks Posted April 13, 2008 Share Posted April 13, 2008 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!";} ?> Link to comment https://forums.phpfreaks.com/topic/100840-solved-php-mail-and-hotmail/#findComment-515898 Share on other sites More sharing options...
raku Posted April 13, 2008 Author Share Posted April 13, 2008 Unfortunately, it still goes to spam. It was also sending it as [email protected], 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 https://forums.phpfreaks.com/topic/100840-solved-php-mail-and-hotmail/#findComment-515908 Share on other sites More sharing options...
darkfreaks Posted April 13, 2008 Share Posted April 13, 2008 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!";} ?> Link to comment https://forums.phpfreaks.com/topic/100840-solved-php-mail-and-hotmail/#findComment-515910 Share on other sites More sharing options...
raku Posted April 13, 2008 Author Share Posted April 13, 2008 Thanks again, but it still doesn't work. I changed the "reply-to" to from_email and from_name, but it still didn't get received. Link to comment https://forums.phpfreaks.com/topic/100840-solved-php-mail-and-hotmail/#findComment-516003 Share on other sites More sharing options...
raku Posted April 13, 2008 Author Share Posted April 13, 2008 Anyone know how to get this to work? Thanks. Link to comment https://forums.phpfreaks.com/topic/100840-solved-php-mail-and-hotmail/#findComment-516086 Share on other sites More sharing options...
darkfreaks Posted April 13, 2008 Share Posted April 13, 2008 best option is to download and use PHPmailer Link to comment https://forums.phpfreaks.com/topic/100840-solved-php-mail-and-hotmail/#findComment-516090 Share on other sites More sharing options...
raku Posted April 13, 2008 Author Share Posted April 13, 2008 I would like to avoid doing that. Are there any alternatives that could make this work with typical php mail()? If anyone has any ideas on how to get this work, I'd greatly appreciate it! Thanks. Link to comment https://forums.phpfreaks.com/topic/100840-solved-php-mail-and-hotmail/#findComment-516148 Share on other sites More sharing options...
raku Posted April 13, 2008 Author Share Posted April 13, 2008 Anyone know how to fix this? Thanks. Link to comment https://forums.phpfreaks.com/topic/100840-solved-php-mail-and-hotmail/#findComment-516369 Share on other sites More sharing options...
raku Posted April 14, 2008 Author Share Posted April 14, 2008 I ended up going with phpmailer. Thanks for your help. Link to comment https://forums.phpfreaks.com/topic/100840-solved-php-mail-and-hotmail/#findComment-516401 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.