-
-
Save jalbertbowden/a5c49c256bc9d5e3acf6a1ef306030df to your computer and use it in GitHub Desktop.
Using PHP Mailer to Send HTML Emails with Images
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| require("class.phpmailer.php"); | |
| $mail = new PHPMailer();$mail = new PHPMailer(); | |
| $mail->IsSMTP(); | |
| $mail->Host = "smtp1.example.com;smtp2.example.com"; | |
| $mail->SMTPAuth = true; | |
| $mail->Username = 'smtpusername'; | |
| $mail->Password = 'smtppassword'; | |
| $mail->From="[email protected]"; | |
| $mail->FromName="My site's mailer"; | |
| $mail->Sender="[email protected]"; | |
| $mail->AddReplyTo("[email protected]", "Replies for my site"); | |
| $mail->AddAddress("[email protected]"); | |
| $mail->Subject = "Test 1"; | |
| $mail->IsHTML(true); | |
| $mail->AddEmbeddedImage('logo.jpg', 'logoimg', 'logo.jpg'); // attach file logo.jpg, and later link to it using identfier logoimg | |
| $mail->Body = "<h1>Test 1 of PHPMailer html</h1> | |
| <p>This is a test picture: <img src=\"cid:logoimg\" /></p>"; | |
| $mail->AltBody="This is text only alternative body."; | |
| if(!$mail->Send()) | |
| { | |
| echo "Error sending: " . $mail->ErrorInfo;; | |
| } | |
| else | |
| { | |
| echo "Letter is sent"; | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment