email sending reply to and mail from

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
vintoICT
User
Posts: 432

email sending reply to and mail from

Post by vintoICT »

I believe phpmaker uses phpmailer for emails. I need to change the email from to another value I don't want to use the default email in //Server settings.

//sample from phpmailer
    $mail->setFrom('from@example.com', 'Mailer');
       $mail->addReplyTo('info@example.com', 'Information');
$mail->Subject = 'Here is the subject';

// PHPmaker code (emailsending)
 $email->From='demo2@gmail.com';
                 $sEmail_List = "".$msgto.""; 
                  $email->Recipient = $sEmail_List; // Change recipient to a field value in the new record
                  $email->Subject=$subject;

I need the right code for
$email->From and $email->Replyto


mobhar
User
Posts: 11851

Post by mobhar »

You may use Sender instead of From.


vintoICT
User
Posts: 432

Post by vintoICT »

$email->Sender='demo2@gmail.com'; not working


arbei
User
Posts: 9618

Post by arbei »

You need to post your complete code. Where is your $email from? From Email_Sending event?


vintoICT
User
Posts: 432

Post by vintoICT »

// Email Sending event
    public function emailSending($email, $args)
    {
        $rsnew = $args["rsnew"];
          $sAFileName = $this->attachment->attacment."/" . $Args["rsnew"]["attachment"] ;  
                    $surname=CurrentUserinfo("surname");
                    $firstname=CurrentUserinfo("firstname");
                    $othername=CurrentUserinfo("othername");
                    $fullname="$surname $firstname ";
                    $senderemail=CurrentUserinfo("email");
                        $msgto=$rsnew["msgto"];
                        $msg=$rsnew["message"];
                        $subjecttemp=$rsnew["subject"];
                        $subject= strtoupper($subjecttemp);
                      $state= $rsnew["state"];
                  $location=$rsnew["location"];
                  $priority=$rsnew["priority"];
                  $alert=$rsnew["alerttype"];
                  $details=$rsnew["details"];
                  $email->Sender = "".$senderemail."";  
                 $sEmail_List = "".$msgto.""; 
                  $email->Recipient = $sEmail_List; // Change recipient to a field value in the new record
                 
                  $email->Subject=$subject;
                
                                  $email->Content = '
                                  <p> <center>'.$subject.'</center></p>
       <p> 
       <p>From: '.$senderemail.'</p>
       <p>To: '.$msgto.'</p>
    <p>Cc:</p>
       </p>
          <p>Dear Sir/Madam,</p>
        <p>
        This email was sent by <b>('.$fullname.')</b>from the <b>Company name</b>HR application please find the details below:<br>
        </p>
        <p>'.$msg.'</p>
        Best Regards,<br>
        Support
        </p>
               '; 
               $email->Format = "html";
               $email->addAttachment($sAFileName);

               // start content from beginning here
                        return true;

arbei
User
Posts: 9618

Post by arbei »

vintoICT wrote:

                    $senderemail=CurrentUserinfo("email");
                  $email->Sender = "".$senderemail."";  

You better check if your $senderemail has valid email using Log("sender = " . $senderemail) (then check the result in the log file) or die("sender = " . $senderemail).


vintoICT
User
Posts: 432

Post by vintoICT »

sender = vintoict@gmail.com

the email is correct .

This is my email settings

"SMTP" => [
"PHPMAILER_MAILER" => "smtp", // PHPMailer mailer
"SERVER" => "mail.mysite.com", // SMTP server
"SERVER_PORT" => 465, // SMTP server port
"SECURE_OPTION" => "ssl",
"SERVER_USERNAME" => "info@mysite.com", // SMTP server user name
"SERVER_PASSWORD" => "********", // SMTP server password
The email is been sent as info@mysite.com. I want it to be dynamic
$senderemail=CurrentUserinfo("email");
$email->Sender = "".$senderemail."";


arbei
User
Posts: 9618

Post by arbei »

You may enable Debug and send email again. Then check the PHPMailer logs in the log file for errors.


Post Reply