I would like to use a form to send a verification email though mailgun to users when they sign up for a service. I have a form collecting the required info for the email but need to put it into the email. The problem is the way the email is formatted and I do not know how to print the data.
Here is my action:
<?php
require 'vendor/autoload.php';
use Mailgun\Mailgun;
$mgClient = new Mailgun('MY-API-KEY');
$domain = "https://api.mailgun.net/v3/MY-DOMAIN";
$result = $mgClient->sendMessage($domain, array(
'from' => 'Verifier <MY-ADDRESS>',
'to' => '<?php print_r(GET_$[email]) ?>, second-address#email.com',
'subject' => 'Verifcation & Instructions',
'text' => 'Dear print_r(GET_$[username]),
Thank you for requesting a service for print_r(GET_$[url]).
To make sure this was you, please click here and verify ...'
));
?>
I know the send is working because of the second address I have set up.
Thanks for any help!
Here is a possible solution as given to me by Mailgun Support:
http://blog.mailgun.com/double-opt-in-with-php-mailgun/
Related
I am trying to trigger the send of a smart transactional email in Campaign Monitor from my Wordpress app
require_once( get_stylesheet_directory() . '/createsend-php-master/csrest_transactional_smartemail.php' );
# Authenticate with your API key
$auth = array('api_key' => 'apikey');
# The unique identifier for this smart email
$smart_email_id = 'emailid';
# Create a new mailer and define your message
$wrap = new CS_REST_Transactional_SmartEmail($smart_email_id, $auth);
$message = array(
"To" => 'email#email.com',
"Data" => array(
'x-apple-data-detectors' => 'x-apple-data-detectorsTestValue',
'href^="tel"' => 'href^="tel"TestValue',
'href^="sms"' => 'href^="sms"TestValue',
'owa' => 'owaTestValue',
),
);
# Send the message and save the response
$result = $wrap->send($message);
I've got the correct API and Email ID, and I'm using my gmail account to test with but the email just isn't getting triggered. I'm a beginner coder and I reckon I've just missed something completely obvious!
Path to the campaign monitor php file is correct too.
The API documentation is here https://www.campaignmonitor.com/api/transactional/?_ga=1.180877863.1694927084.1483423346 - is there anything I've missed out. Help is much appreciated!
This code is working for a single recipient but not for multiple recipients.How should I add multiple recipient into send() function in here.
//find price
$price = MDealPrice::model()->find("id=:id", array(':id' => $id));
// find deal
$deal = MDeal::model()->find("id=:id", array(':id' => $price->dealId));
//send email
app()->mailer->send($sendEmailAdd, 'orderAuthorizeEmail', array('deal' => $deal));
I tried like this also, But not worked.
//send email
app()->mailer->send(array('email1#domain.com','email2#domain.com'), 'orderAuthorizeEmail', array('deal' => $deal));
Thanks in advance!
Please try with below solution it will work
app()->mailer->send('email1#domain.com,email2#domain.com', 'orderAuthorizeEmail', array('deal' => $deal));
just add your email ids comma separated string in send function instead to pass array of email ids.
I am working on Yii and I need to send a confirmation email one sign up. The content shows the email as abc%40#example.com
the email is directly called from the database and added to the mail function
I am not sure how this can be fixed
$activation_url = $this->createAbsoluteUrl('/user/activation/activation',array("activkey" => $registerform->activkey, "email" => $registerform->email));
the above code is the sample
Any help is appreciated
Apologies
the result is shown like this abc%40example.com and not abc%40#example.com
Try this:
$activation_url = $this->createAbsoluteUrl('/user/activation/activation',array("activkey" => $registerform->activkey, "email" => urldecode($registerform->email)));
Is there anyway to get a user's email without a form in php? I want to able to send someone an email for a mailing list and instead of them filling out a form where they enter their email, the php page I have linked in the email. They click the link and it sends them to a thank-you page on the site. Then it stores their IP, date/time and email in a database I have set up. I've completed this with a form, but I'm wondering if there's any possible way to do it without a form. Here's my code for the form, I'm using Drupal form API. I've been googling this for hours, but have found nothing. I saw something about URL parameters, but it didn't really pertain to my question. Any help is appreciated.
<?php
//This custom module will be used on the website to gain consent from our clients because of the recent CASL anti spam laws that were passed in Cnada.
//Menu hook starts here, implements menu and sets the title, url of the page.
function form_casl_menu() {
$items = array();
$items['casl-consent/form'] = array( //this creates a URL that will call this form at "url"
'title' => 'CASL Subscription', //page title
'description' => 'A form that allows us to send emails to clients with their consent.',
'page callback' => 'drupal_get_form', //this is the function that will be called when the page is accessed. for a form, use drupal_get_form
'page arguments' => array('form_casl_form'), //put the name of the form here
'access callback' => TRUE
);
return $items;
}
//permission hook
function form_casl_permission() {
return array(
'administer my module' => array(
'title' => t('Administer my module'),
'description' => t('Perform administration tasks for my module.'),
),
);
}
//form hook, form elements start here
function form_casl_form($form, &$form_state) {
//sometext here
$form['some_text'] = array(
'#markup' => '<p><b>Simply enter your email address to subscribe</b>
</p>'
);
$form['email'] = array(
'#type' => 'textfield', //their email
'#title' => 'Email:',
'#size' => 30,
'#maxlength' => 150,
'#required' => TRUE,
);
//submit button
$form['submit_button'] = array(
'#type' => 'submit',
'#value' => t('Submit Data'),
);
return $form;
}
//validate hook
function form_casl_form_validate($form, &$form_state) { //invalid email error
if (!valid_email_address($form_state['values']['email'])) {
form_set_error('mail', t('You must enter a valid e-mail address.'));
}
}
//submit hook
function form_casl_form_submit($form, $form_state) {
$sDate = date("Y-m-d H:i:s"); //returns the date and time
global $name;
$subbed = 'Yes';
//----------------------------------------------------------------\\
$ip55 = &drupal_static(__FUNCTION__);
//ip get function, returns a clients IP address and checks if they're behind a proxy.
if (!isset($ip55)) {
$ip55 = $_SERVER['REMOTE_ADDR'];
if (variable_get('reverse_proxy', 0)) {
$reverse_proxy_header = variable_get('reverse_proxy_header', 'HTTP_X_FORWARDED_FOR');
if (!empty($_SERVER[$reverse_proxy_header])) {
// If an array of known reverse proxy IPs is provided, then trust
// the XFF header if request really comes from one of them.
$reverse_proxy_addresses = variable_get('reverse_proxy_addresses', array());
// Turn XFF header into an array.
$forwarded = explode(',', $_SERVER[$reverse_proxy_header]);
// Trim the forwarded IPs; they may have been delimited by commas and spaces.
$forwarded = array_map('trim', $forwarded);
// Tack direct client IP onto end of forwarded array.
$forwarded[] = $ip55;
// Eliminate all trusted IPs.
$untrusted = array_diff($forwarded, $reverse_proxy_addresses);
// The right-most IP is the most specific we can trust.
$ip55 = array_pop($untrusted);
}
}
}
//-----------------------------------------------------------------\\
//inserting data into database
db_insert('CASL')
->fields(array(
'email' => $form_state['values']['email'],//email
'ip' => $ip55,//ip
'substatus' => $subbed,
'datetime' => $sDate,//date and time
))->execute();
//sending confirmation email to the user, letting them know they can unsub at any time.
$values = $form_state['values'];
$to = $form_state['values']['email'];
$subject = 'Confirmation';
$message ="Thank you for your submission. You may unsubscribe at any time by refilling out this form http://www.localhost.ca/casl-consent/form and selecting the 'unsubscribe' option. Or, you can simply email us a request to unsubscribe, and we will remove you from our database immediately.
If you have any questions or concerns, you can email us at this link: http://www.localhost.ca/contact";
mail($to, $subject, $message);
drupal_set_message("Thank you! Your information has been received successfully and you have been sent a confirmation email.");
//thank you message after submission
}
?>
Based on your comment, it sounds like you are attempting to associate a known email address to an IP address. You say you are sending an email and they are clicking a link. I'm making the assumption that each of these links on each email is uniquely generated an associated to a specific address. In that case, your problem comes down to "How do I find a client's IP address?".
In PHP, you can do this using $_SERVER['REMOTE_ADDR']. This is the most reliable, but by no means fool proof.
'REMOTE_ADDR'
The IP address from which the user is viewing the current page.
If the user is behind a proxy, the $_SERVER['HTTP_X_FORWARDED_FOR'] may have been set, but this value can be spoofed by both the client and the proxy. It's not guaranteed to be accurate and shouldn't be trusted. If the user if using a proxy, though, the value in REMOTE_ADDR will be the IP address of the proxy that hits your webserver, not that of the client.
So, assuming you are going to use REMOTE_ADDR, how do you associate the email address to the IP address?
The user clicks a unique link that you have stored with the known email address. That link runs a very simply script and looks at REMOTE_ADDR and maybe HTTP_X_FORWARDED_FOR and you store those two values.
Your table should be as simple as this:
email_address | unique_link | remote_addr | http_x_forwarded_for
The last two values are filled out once the user clicks the unique_link. How you populate email_address initially, remains your secret.
I am trying to create tickets on my Zendesk and that is working fine. However i do not want Zendesk to email the creator of the tickets (his or her email). Is this possible?
The idea is i have a contactForm widget on my site, i want the submits from this form to create tickets in my Zendesk.
Creating tickets is currently working using this code:
$zendesk = new zendesk(
$row->api_key,
$row->email_address,
$row->host_address,
$suffix = '.json',
$test = false
);
$arr = array(
"z_subject"=>"Offline Message",
"z_description"=> $r->contact_msg,
"z_recipient"=>$r->contact_email,
"z_name"=>$r->contact_name,
);
$create = json_encode(
array('ticket' => array(
'subject' => $arr['z_subject'],
'description' => $arr['z_description'],
'requester' => array('name' => $arr['z_name'],
'email' => $arr['z_requester']
))),
JSON_FORCE_OBJECT
);
$data = $zendesk->call("/tickets", $create, "POST");
Any ideas?
Totally possible! You need to add some conditions to the trigger "Notify requester of received request" in Zendesk - Trigger setting to prevent zendesk from sending email. For ex:
Ticket : Channel - Is Not - Webservice (API)
Ticket : Tags - Contains one of the following - "offline message"
You could use another API endpoint "Ticket Import" https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_import/
It's do not send notifications