Hej
Jeg forsøger at sende emails til aktivering af brugere på
http://www.painters.dkNår jeg opretter en bruger modtager jeg ingen mails.
Koden til at sende mails:
<?php
function sendEmail($receiver, $subject, $message) {
$email_text = "<html>\n";
$email_text .= "<head>\n";
$email_text .= "<title>$subject</title>\n";
$email_text .= "</head>\n";
$email_text .= "<body>\n";
$email_text .= "<a href=\"http://www.painters.dk\" target=\"_blank\"><img src=\"http://www.painters.dk/_img/logo/purple.gif\" alt=\"Painters\" title=\"Painters\" style=\"width:104px;height:64px;\"></a><br>\n";
$email_text .= str_replace("\n.", "\n..", wordwrap($message, 70));
$email_text .= "</body>\n";
$email_text .= "</html>\n";
$email_header = "MIME-Version: 1.0\r\n";
$email_header .= "Content-type: text/html; charset=iso-8859-1\r\n";
$email_header .= "To: $receiver\r\n";
$email_header .= "From: Painters <painters@painters.dk>\r\n";
$email_header .= "Reply-To: Painters <painters@painters.dk>\r\n";
$email_header .= "X-Mailer: PHP/".phpversion();
return mail( $receiver, $subject, $email_text, $email_header );
}
function sendEmailSimple($receiver, $subject, $message) {
$email_text = str_replace("\n.", "\n..", wordwrap($message, 70));
$email_header = "From: painters@painters.dk\n";
$email_header .= "Reply-To: painters@painters.dk\n";
$email_header .= "X-Mailer: PHP/".phpversion();
return mail( $receiver, $subject, $email_text, $email_header );
}
?>
Og koden til at oprette en bruger ($code er en md5 krypteret streng):
$name="Niels";
$email="navn@domain.dk";
$activation_link = "http://www.painters.dk/_do/users/activate.php?user=$newuser_grabbed_id&code=$code";
$email_str = "<big>Hurra det lykkedes!</big><br>\n";
$email_str .= "<br>\n";
$email_str .= "Hej $name<br>\n";
$email_str .= "<br>\n";
$email_str .= "Her er din aktiveringskode: $code<br>\n";
$email_str .= "<br>\n";
$email_str .= "Du skal bare lige klikke på linket du finder nedenfor så er din bruger aktiveret =)<br>\n";
$email_str .= "<a href=\"$activation_link\" target=\"_blank\">$activation_link</a><br>\n";
$email_str .= "<br>\n";
$email_str .= "Endnu engang velkommen.<br><br><br>\n";
$email_str .= "Venlig Hilsen<br>\n";
$email_str .= "Painters<br>\n";
if(sendEmail($email, "Aktiveringslink", $email_str)
&& sendEmailSimple($email, "Aktiveringslink", $email_str)) {
message_add("Velkommen til MalerUngdom.", "good");
return true;
} else {
message_add("Kunne ikke sende e-mail med linket til at aktivere din bruger.", "error");
return false;
}