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! Quote Link to comment 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: support@voteoften.us\r\n" . "X-Mailer: php" .phpversion() . "\r\n"; Quote Link to comment 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: support@domain.com X-Mailer: php5.1.6 Quote Link to comment 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: support@domain.com' . "\r\n"; $additional_parameters = "-f support@domain.com"; mail($to, $subject, $body, $headers, $additional_parameters); Any help is greatly appreciated. Quote Link to comment 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! Quote Link to comment 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: support@domain.com' . "\r\n"; $headers.= "-f support@domain.com"; mail($to, $subject, $body, $headers); ?> Quote Link to comment 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 support@domain.com" Quote Link to comment 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: ' . 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"; ?> Quote Link to comment 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 = "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! Quote Link to comment 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);?> Quote Link to comment 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";?> Quote Link to comment 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 = "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. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted April 13, 2008 Share Posted April 13, 2008 Read up on MIME boundaries Quote Link to comment 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. Quote Link to comment 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 = "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); ?> Quote Link to comment 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. Quote Link to comment 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 = "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!";} ?> Quote Link to comment 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 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. Quote Link to comment 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 = "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!";} ?> Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.