Showing posts with label PHP Mailer. Show all posts
Showing posts with label PHP Mailer. Show all posts

Friday, 2 August 2019

How to change the Return-path email address using the PHPMailer class

Fill the $Sender property with the email address you wish to have as the Return-path 
E.g.
$mail->Sender="test@testmail.com";
This property can be found on Line 97 in the class.phpmailer.php file 
  /** 
   * Sets the Sender email (Return-Path) of the message.  If not empty, 
   * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode. 
   * @var string 
   */ 
  public $Sender            = '';

How to embed images using PHPMailer

  1. Use the AddEmbeddedImage method provided by the PHPMailer class.
    eg. $mail->AddEmbeddedImage(‘test.gif’,’testImage’,’test.gif’);
  2. Parameters for AddEmbeddedImage($path, $cid, $name = ”, $encoding = ‘base64’, $type = ‘application/octet-stream’)
    1. $path Path to the attachment
    2. $cid = Content ID of the attachment.  Use this to identify the Id for accessing the image in an HTML form.
    3. $name = Overrides the attachment name.
    4. $encoding = File encoding
    5. $type = File extension (MIME) type.
Example:
<?php
          //Include the PHPMailer class
          include = 'class.phpmailer.php';

         $mailer=new phpmailer();
         $mailer->From =’sender@techportal.co.za’;
         $mailer->FromName=’TechPortal';
         $mailer->Subject =’TechPortal Example’;
         $mailer->AddAddress(’recipient@techportal.co.za’);

         $mailer->IsHTML(true);
         $mailer->AddEmbeddedImage(’test.gif’,'testImage’,'test.gif’);
         $mailer->Body =’<img src=”cid:testImage”>’;

         $mailer->Send();
?> 

How to embed images using PHPMailer

  1. Use the AddEmbeddedImage method provided by the PHPMailer class. 
    eg. $mail->AddEmbeddedImage(‘test.gif’,’testImage’,’test.gif’);
  2. Parameters for AddEmbeddedImage($path, $cid, $name = ”, $encoding = ‘base64’, $type = ‘application/octet-stream’)
    1. $path = Path to the attachment
    2. $cid = Content ID of the attachment.  Use this to identify the Id for accessing the image in an HTML form.
    3. $name = Overrides the attachment name.
    4. $encoding = File encoding
    5. $type = File extension (MIME) type.
Example:
<?php
    //Include the PHPMailer class
include = ‘class.phpmailer.php‘;
$mailer=new phpmailer();
$mailer->From =’sender@techportal.co.za’;
$mailer->FromName=’TechPortal’;
$mailer->Subject =’TechPortal Example’;
$mailer->AddAddress(’recipient@techportal.co.za’);
$mailer->IsHTML(true);
 $mailer->AddEmbeddedImage(’test.gif’,’testImage’,’test.gif’);
$mailer->Body =’<img src=”cid:testImage”>’;
$mailer->Send();
?> 

Monday, 3 September 2018

daerPHP Mailer does not issue 'field entry'

The problem I am facing is this: - the PHP script (handled by PHP mailer) is sending an e-mail, but not the information people fill in at the form.
Here is the php script I use:
<?php
$to = "user@domain.com";
$subject = "Request";
$message = "<h1>Request</h1>";
$message .= "<strong>street</strong>: $_POST['street']";
$message .= "<strong>store</strong>: $_POST['store']";
$headers  = "From: request@domain.com";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html\r\n";
$sent = mail($to, $subject, $message, $headers);
if( $sent = mail($to, $subject, $message, $headers) ){ echo "SENT"; } else { echo "There
was a problem"; }
?>

Thanks in advance!

<?php
$to = "user@domain.com";
$subject = "Request";
$message = "<h1>Request</h1>";
$message .= "<strong>street</strong>:".$_POST['street'];
$message .= "<strong>store</strong>:".$_POST['store'];
$headers  = "From: request@domain.com";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html\r\n";
$sent = mail($to, $subject, $message, $headers);
if( $sent = mail($to, $subject, $message, $headers) ){ echo "SENT"; } else { echo "There
was a problem"; }
?>