Page 1 of 1
email sending reply to and mail from
Posted: Sat Nov 11, 2023 3:24 am
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
Re: email sending reply to and mail from
Posted: Sat Nov 11, 2023 9:47 am
by mobhar
You may use Sender
instead of From
.
Re: email sending reply to and mail from
Posted: Sat Nov 11, 2023 12:54 pm
by vintoICT
$email->Sender='demo2@gmail.com';
not working
Re: email sending reply to and mail from
Posted: Sat Nov 11, 2023 1:47 pm
by arbei
You need to post your complete code. Where is your $email
from? From Email_Sending event?
Re: email sending reply to and mail from
Posted: Sat Nov 11, 2023 8:31 pm
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;
Re: email sending reply to and mail from
Posted: Sat Nov 11, 2023 11:04 pm
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)
.
Re: email sending reply to and mail from
Posted: Sun Nov 12, 2023 1:54 am
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."";
Re: email sending reply to and mail from
Posted: Sun Nov 12, 2023 9:04 am
by arbei
You may enable Debug and send email again. Then check the PHPMailer logs in the log file for errors.