SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Guru
    Join Date
    Dec 2005
    Posts
    964
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Mails with inactive links?

    I'm using a php mail class and have had no problems, but somehow the links send in it is inactive... If a link is send it should be blue and clickable... Can somebody please help?!?

    The mail:
    PHP Code:
    require_once('modules/sendmail/mail.php');

    $eol ="\r\n";
    $eol2 ="\r";

    $to "".$firstname." ".$lastname." <".$email.">";
    $from 'My Site <noreply@mysite.com>';
    $subject "Hello ".$firstname."";
    $body "Hello ".$firstname.", $eol2 $eol2";
    $body .= "You are now a member of my site. $eol2 $eol2";
    $body .= "Click on link below to access. $eol2 $eol2";
    $body .= "".$site_url."/index.php?ga=activateuser&code=".$gacode.$eol2 $eol2";
    $body .= "$eol2 $eol2";
    $body .= "This email is autogenerated";

    $mail = new ZFmail($to,$from,$subject,$body);

    $mail->send(); 
    The mail.php:
    PHP Code:
    class ZFmail{
        var 
    $to null;
        var 
    $from null;
        var 
    $subject null;
        var 
    $body null;
        var 
    $headers null;

         function 
    ZFmail($to,$from,$subject,$body){
            
    $this->to      $to;
            
    $this->from    $from;
            
    $this->subject $subject;
            
    $this->body    $body;
        }

        function 
    send(){
          
    $this->addHeader('From: '.$this->from."\r\n");
            
    $this->addHeader('Reply-To: '.$this->from."\r\n");
            
    $this->addHeader('Return-Path: '.$this->from."\r\n");
            
    $this->addHeader('X-mailer: ZFmail 1.0'."\r\n");
            
    mail($this->to,$this->subject,$this->body,$this->headers);
        }

        function 
    addHeader($header){
            
    $this->headers .= $header;
        }


    The mail class is found on the net, but I can't figure out where the script do wrong?!?

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    You're sending HTML content, but the email is still being sent as plain text. The object you're using doesn't appear to support HTML mail.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Guru
    Join Date
    Dec 2005
    Posts
    964
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Where am I sending the html content?

  4. #4
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Sorry, you're not sending HTML, but you need to in order to make the links 'clickable'.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  5. #5
    SitePoint Guru
    Join Date
    Dec 2005
    Posts
    964
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you mean adding a headers.= "Content-type: text/html; charset=iso-8859-1\r\n";?

  6. #6
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Maybe this SitePoint article will help, but essentially yes, you need to send some additional headers for HTML mail.

    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  7. #7
    SitePoint Guru
    Join Date
    Dec 2005
    Posts
    964
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks... I will try it out, but what is there an issue with sending html mails...?

  8. #8
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    As described in the article, you can send a plain text and HTML variant of your message, give the article a read and see if do indeed encounter any issues. If so, just post.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  9. #9
    SitePoint Guru
    Join Date
    Dec 2005
    Posts
    964
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey, read through the article, but I'm actully only interested in the plain text mail, so I tryid this and it sort of works... I now has the links clickable, but the mail send out allways start with 3 breaks/lineshifts before the "Hello Username"... How do I get rid of that?

    The script:
    PHP Code:
    $eol ="\r\n"

    $to "".$firstname." ".$lastname." <".$email.">"
    $subject "Hello ".$firstname.""
    $body "Hello ".$firstname.", $eol $eol"
    $body .= "You are now a member of my site. $eol $eol"
    $body .= "Click on link below to access. $eol $eol"
    $body .= "".$site_url."/index.php?ga=activateuser&code=".$gacode.$eol $eol"
    $body .= "$eol $eol"
    $body .= "This email is autogenerated"

    $headers "From: My Site <noreply@mysite.com>"."$eol";
    $headers .= "Reply-To: My Site <noreply@mysite.com>"."$eol";
    $headers .= "Return-Path: My Site <noreply@mysite.com>"."$eol";
    $headers .= "Message-ID: <".time()."-noreply@mysite.com>"."$eol";
    $headers .= "X-Mailer: PHP v".phpversion().$eol;
    $headers .= 'MIME-Version: 1.0'.$eol.$eol;

    if(!
    mail($to,$subject,$body,$headers)){
       die (
    "".__DIE."");



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •