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

Coolness. I’ll get testing shortly :smiley:

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.

Wicked.

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

Thanks for your speedy response, aidos :slight_smile:

I would really go for PHPMailer which has lots of features. I have been using for last 3 years.

Thank you rajug, I will look into this shortly :slight_smile:

You’re welcome :slight_smile: and if you need a tute on how to send html emails using php mail, this is a pretty good one.

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.


<img src="http://www.mysite.com/img1.jpg" />

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.

If you are following PHPMailer then you have two ways to send images:


$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.

Wicked. I’ll definitely look into this just now.

Thank you Rajug

Quick question :slight_smile:


$mail->MsgHTML(file_get_contents('contents.html'));

Is this looking for ‘contents.html’ in the phpmailer directory?

Generally it will search the file where your current script file is located (or is being included).