SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Wizard
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    1,285
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Send 'HTML Email' with PHP?

    Hi,

    Bit of a simple question this.

    I'm comfortable with producing and distributing HTML emails, but wonder can I send HTML Emails automatically with PHP?

    I'm hoping that if a user signs up on my site I can automatically send an HTML Email response to them. Just like an eNewsletter.

    Can anyone point me in the right direction of where to start?



    Many thanks

  2. #2
    Non-Member
    Join Date
    Dec 2010
    Location
    /home/pc
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After the new user's details have been entered into your database, you can use php's mail to send a plain text and/or html email welcoming them.

  3. #3
    SitePoint Wizard
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    1,285
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wicked.

    I've really got to look at the manual more often.


    Thanks for your speedy response, aidos

  4. #4
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would really go for PHPMailer which has lots of features. I have been using for last 3 years.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  5. #5
    SitePoint Wizard
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    1,285
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you rajug, I will look into this shortly

  6. #6
    Non-Member
    Join Date
    Dec 2010
    Location
    /home/pc
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by invision2 View Post
    Wicked.

    I've really got to look at the manual more often.


    Thanks for your speedy response, aidos
    You're welcome and if you need a tute on how to send html emails using php mail, this is a pretty good one.

  7. #7
    SitePoint Wizard
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    1,285
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for this.

    Can you confirm I can also attach images to this Email, so images can be used in the design?

    Or would I have to use an absolute path pointing back to the server e.g.
    HTML Code:
    <img src="http://www.mysite.com/img1.jpg" />

  8. #8
    Non-Member
    Join Date
    Dec 2010
    Location
    /home/pc
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can attach images to the email to send as an attachment to the recipient but you will have to specify the correct mime type for the image in your php code (see the tute at the link I posted).

    If you want to use an image in your html design for the email then you need to specify the absolute path to the image in the src for the <img /> starting from http://blahblah as you did.

  9. #9
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you are following PHPMailer then you have two ways to send images:
    PHP Code:
    $mail->AddEmbeddedImage() // to embed the images in the email body with some token defined in the raw mail body.
    $mail->AddAttachment() // to attach the image 
    See more examples in the link mentioned above.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  10. #10
    SitePoint Wizard
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    1,285
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wicked. I'll definitely look into this just now.

    Thank you Rajug

  11. #11
    SitePoint Wizard
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    1,285
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quick question

    PHP Code:
    $mail->MsgHTML(file_get_contents('contents.html')); 
    Is this looking for 'contents.html' in the phpmailer directory?

  12. #12
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Generally it will search the file where your current script file is located (or is being included).
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  13. #13
    SitePoint Wizard
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    1,285
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Coolness. I'll get testing shortly


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
  •