jacksoggetto Posted July 10, 2018 Share Posted July 10, 2018 I want to use the sendmail api to send emails to my clients this is easy but, is it possible to send them from a different email and name? I want to send from my private email and pretend it was me sending it directly to my client. I better ask before writing the code to send the email 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted July 10, 2018 Share Posted July 10, 2018 Yes, it's possible but not via SendEmail API since it doesn't allow you to change the address on the fly. When I was using the old WHMCS v5 I had to find a workaround. As far as I know no changes have been made to SendEmail API therefore my workaround should be still valid. You have to make the long ride interacting directly with PHPMailer that is placed in vendor folder. You should do something like this: <?php require_once( ROOTDIR . '/vendor/phpmailer/phpmailer/PHPMailerAutoload.php'); $mail = new PHPMailer; $mail->IsSMTP(); $mail->CharSet = 'UTF-8'; /** * Here you should retreive all information from WHMCS (recipients, customers, variables...) */ try { $mail->Host = 'mailserver.example.com; $mail->SMTPAuth = true; $mail->Port = 99999; $mail->Username = 'yourMailServer-Username'; $mail->Password = 'yourMailServer-Password'; $mail->AddAddress('recipient@example.com', 'Definitely not Jodie Foster'); $mail->SetFrom('youremail@example.com', 'Definitely not Rambo'); $mail->Subject = 'You won 1.000.000 $!'; $mail->MsgHTML('The pen is on the table... <strong>DAMN IT!</strong>'); $mail->Send(); //echo "Message Sent</p>\n"; } catch (phpmailerException $e) { //echo $e->errorMessage(); //Pretty error from PHPMailer } catch (Exception $e) { //echo $e->getMessage(); //Boring error from anything else! } Of course you can use the same approach also inside a foreach in case you need to send emails to multiple clients. 0 Quote Link to comment Share on other sites More sharing options...
jacksoggetto Posted July 10, 2018 Author Share Posted July 10, 2018 thanks, very helpful, I'll put all this into a function and then create my hook 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.