anthonybudd / wp_mail Goto Github PK
View Code? Open in Web Editor NEWSend Templated emails with WordPress
License: MIT License
Send Templated emails with WordPress
License: MIT License
Hi,
How can I send and email only if some conditions are satisfied based on the content in template added via template() function of your class.
Thanks!
$email = WP_Mail::init()
->to([
'[email protected]'
'[email protected]'
])
->cc('[email protected]')
When use like this, all receviers can view all emails in to
section. Is anyway to show only recever mail?
As mentioned in the title, Wordpress return me 0.
I require WP_Ajax and WP_Mail.
This is my code
`
Class Example extends WP_AJAX
{
protected $action = 'example';
protected function run(){
if (filter_var($this->get('email'), FILTER_VALIDATE_EMAIL)) {
$mymail = get_option( 'simplebooks_news_contact_mail',get_userdata(1)->user_email);
$email = WP_Mail::init()
->headers([
"From: ".$this->get('email'),
"Content-type: text/html; charset=iso-8859-1",
"MIME-Version: 1.0\n",
"X-Mailer: PHP " . phpversion()
])
->from($this->get('email'))
->to([$mymail,$this->get('email')])
->subject(__('New contact from enquiry','simplebooks').': {{name}}')
->template(get_template_directory() .'/emails/basic.html', [
'time' => date('Y-m-d H:i:s'),
'name' => $this->get('name').' '.$this->get('surname'),
'email' => $this->get('email'),
'message' => $this->get('message'),
])
->send();
}
}
}
`
and this the form
echo'<h2 class="ui header">'.get_option( 'simplebooks_news_contact_text',__('Contact me! Send me a mail!','simplebooks')).'</h2>
<form class="emailform" action="'.Example::url().'">
<div class="ui form text container mail-form">
<div>
<textarea id="message" class="mail-text" name="message" placeholder="'.__('Write me a message...','simplebooks').'"></textarea>
<div class="ui fields mail-input mail-hidden">
<div class="ui left icon input field mail-input mail-hidden">
<input class="mail-hidden" type="text" name="name" placeholder="'.__('Name','simplebooks').'">
<i class="user icon"></i>
</div>
<div class="ui field mail-hidden">
<input class="mail-hidden" type="text" name="surname" placeholder="'.__('Surname','simplebooks').'">
</div>
</div>
<div class="ui left icon input mail-input mail-hidden">
<input id="email" class="mail-hidden" type="email" name="email" placeholder="'.__('Your email','simplebooks').'">
<i class="envelope outline icon"></i>
</div>
</div>
<div>
<input id="website" class="no_spam" type="text" name="website">
<button class="ui icon button mail-submit disabled"><i class="envelope outline icon"></i><span class="mail-hidden">'.__(' Send','simplebooks').'</span></button>
</div>
</div>
</form>
';
What am I doing wrong?
Hi Anthony,
Does your class support sending multi MIME emails? I would like to generate email with plain text and html contents
References:
https://gist.github.com/tylermakin/d820f65eb3c9dd98d58721c7fb1939a8
M.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.