SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Evangelist barbara1712's Avatar
    Join Date
    Apr 2007
    Location
    India
    Posts
    509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Sending the mail in html and css format

    Hello,

    I want to send an email in php.
    Tn my message to be sent to sender, I have a table.I have written stylesheet class to a table, th,etc.
    But in the mail ,the class of the stylesheet is not getting applied.

    eg like
    $msgText="<html><body><table cellpadding='1' cellspacing='2' width='500' align='center' class='mytable'>";

    Could anyone please help me out for this.

  2. #2
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    are u sending the defination of css in mail also ?
    what r u sending in headers ?
    can we c complete code ?

  3. #3
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try something like this

    PHP Code:
    $msgText="<html><body><table cellpadding='1' cellspacing='2' width='500' align='center' style='margin-left: 15px; margin-right: 5px'>"

  4. #4
    SitePoint Evangelist barbara1712's Avatar
    Join Date
    Apr 2007
    Location
    India
    Posts
    509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First I have tried this
    1)$msgText="<html><body><table cellpadding='1' cellspacing='2' width='500' align='center' class='mytable'>";
    But for my table class 'mytable' is not applying.
    Then I have used
    2) $msgText="<html><body><table cellpadding='1' cellspacing='2' width='500' align='center' style='background-color :#E6E6FA;border:1px solid #7B68EE; font-size:12px;'>"
    This is working properly.

    But I want to use css class for my table.
    In headers I have set as
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

    Then,I have also used
    $headers .= 'Content-type: text/css; charset=iso-8859-1' . "\r\n";

    But in first case(1) I am not getting the output as in case(2)

  5. #5
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    defination of class='mytable' is not reachable to other end. i mean when u r sending the mail at other end this defination of "mytable" is missing. so try to declare it in mail msg.
    PHP Code:
    for ex $msgText="<style> .mytable{background-color :#E6E6FA;} </style>";
            
    $msgText .=  "<html><body><table cellpadding='1' cellspacing='2' width='500' align='center' class='mytable'>"

  6. #6
    SitePoint Evangelist barbara1712's Avatar
    Join Date
    Apr 2007
    Location
    India
    Posts
    509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot,

    It's working properly with all the formatting.

    and i also have tried
    for ex :
    $msgText="<html><link rel='stylesheet' href='style1.css' /></head>";
    $msgText .= "<body><table cellpadding='1' cellspacing='2' width='500' align='center' class='mytable'>";

    But not working.Isn't it possible?

    Thanks,

  7. #7
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use Absolute Path
    This is possible only when u r giving path of css like this

    PHP Code:
    $msgText="<html><link rel='stylesheet' href='www.mysite.com/CSS_Folder_Name/style1.css' /></head>";
    $msgText .= "<body><table cellpadding='1' cellspacing='2' width='500' align='center' class='mytable'>"

  8. #8
    SitePoint Evangelist barbara1712's Avatar
    Join Date
    Apr 2007
    Location
    India
    Posts
    509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks,

    It's also working.

    Thanks for solving the problem

  9. #9
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Welcome…
    Do you know why ur 1st script is not working?

  10. #10
    SitePoint Evangelist barbara1712's Avatar
    Join Date
    Apr 2007
    Location
    India
    Posts
    509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah,

    the class applied to table was missing.
    rt?

  11. #11
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    u need to R & D.
    view source the mail in which ur script was not working may be u’ll get the answer

  12. #12
    SitePoint Guru SSJ's Avatar
    Join Date
    Jan 2007
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I thnk class is missing


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
  •