脚本宝典收集整理的这篇文章主要介绍了如何使用带有php库的xsmtp-api将替换标签添加到SendGrid中的电子邮件主题,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
问题是我似乎无法实现这一目标.
起初我可能是因为我已经在电子邮件正文中使用了%name%sub,所以我创建了一个新的替换参数名称%namesubject%,
然而,它不会起作用.
/** @description WrapPEr method in order to handle possible exception due to PRogrammer\ maintainer errors. A part of a small wrapper class that I have designed to allow 1-line comfortable use of the the SendGrid and transport classes. @returns int - 1,unless there is an internal error,or an exception thrown */ public function execute(){ if(!class_exists('SendGrid') || !class_exists('SendGrid\Mail')){ throw new exception('Dependency exception SendGrid or SendGrid\Mail are not included'); } if(!isset($this->mailingList) && empty($this->mailingList) || sizeof($this->mailingList) == 0){ throw new exception('Cannot send an email to an empty set of addresses'); } if(!isset($this->subject,$this->body) || empty($this->subject) || empty($this->body)){ throw new exception('Cannot send an email wIThout both a subject and a body'); } $sendgrid = new SendGrid(SENDGRID_USER,SENDGRID_PASSWORD); // $this->importMailList(); foreach($this->mailingList as $key => $val) { $this->mail->addTo($key,$val); } $this->mail-> setFrom($this->fromMail)-> setSubject($this->subject)-> setText($this->text)-> setHtML($this->body); if(preg_match('/%name%/',$this->body) && !array_filter($this->mailingList,'is_int') ){ $this->mail->addSubstitution("%name%",array_values($this->mailingList)); } return $sendgrid->smtp->send($this->mail); }
任何帮助都很受欢迎!
以上是脚本宝典为你收集整理的如何使用带有php库的xsmtp-api将替换标签添加到SendGrid中的电子邮件主题全部内容,希望文章能够帮你解决如何使用带有php库的xsmtp-api将替换标签添加到SendGrid中的电子邮件主题所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。