I am running the following code (I've hidden ID's) to update a subscriber's email address in a MailChimp list:
$mailchimp->patch('lists/1234567/members/' . md5('test#test.com'), [
'email_address' => 'new-email#newtest.com',
'status' => 'subscribed',
'merge_fields' => array(
'FNAME' => 'Ben',
'LNAME' => 'Sinclair',
),
]);
It does not seem to work. I do not receive any errors, it just does nothing.
How do you update an email address in a MailChimp list using API V3?
http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#edit-patch_lists_list_id_members_subscriber_hash
Currently, the email address is a parameter (read only = false) in the PUT method (.../3.0/lists/{listId}/members/{md5}) that allows to change the email address of the subscriber.
I'm sending the new email in the body and MERGE0 (EMAIL) tag but using the md5 from the previous email. It is changing the email correctly.
You can change the email address when you make the request
PUT https://usx.api.mailchimp.com/3.0/lists/{list_id}/members/{subscriber_hash}
and the body was this:
{"email_address": "new#email.com"}
$List = 123456;
$subscriber_hash = md5("old#email.com")
$data = array('email_address' => "new#email.com" );
$result = $mailchimp->put("lists/$List/members/$subscriber_hash", $data);
Related
Hello Guys And Hi I Have This Validation Inside My Request
public function rules()
{
return [
'email' => 'required|email|unique:admins,email,' ,
'name' => 'required|unique:admins,name',
'code' => 'required|min:2|unique:admins,code',
'password' => 'required|min:8',
];
}
I want to ignore an email when updating data during the unique check. For example, consider an "update profile" screen that includes the user's name, e-mail address, I want to verify that the e-mail address is unique. However, if the user only changes the name field and not the e-mail field, I do not want a validation error to be thrown because the user is already the owner of the e-mail address. I only want to throw a validation error if the user provides an e-mail address that is already used by a different user.
I'm Fixing It I'm Passing The Id To The Request Like This
<input name='id' value="$item -> id" hidden >
and i write in Validation
'email' => 'required|email|unique:admins,email,' . $this -> id ,
$user_details=DB::table('table_users')
->select('table_users.*')
->where('id', $user_id)
->first();
\Mail::send('Invoice', array(
'name' => $user_details->name,
'email' => $user_details->email,
'subject' =>'Order is placed',
), function($message) use ($req){
$message->from($user_details->email);
$message->to('xyz#gmail.com', 'Admin')->subject('Order is Placed');
});
I am sending mail in laravel 5.7. My from email id in $user_details->email but it can not get in $message->from($user_details->email).
Since you're using annoymous function as the callback you need to pass the email in use() function as below:
use ($user_details){
you're not using $req neither it's defined anywhere you shared your code here so i think get rid of that if not needed.
I'm new to Laravel and trying to fix a email validation message. The scenario is:
If I send empty value, the validator returns a response "The User Email field is required".
If I send an invalid value like 'my_email_id' [ without # sign ], it still returns "The User Email field is required".
If I send empty value like 'my_email_id#domain', it still returns "The User Email must be a valid email address.".
Now, my question is how can I return the response "The User Email must be a valid email address." for Case 2 as well? Is there any way or is it just how Laravel does it by default?
Thanks.
You should make it with your custom validation message like this :
$rules = array(
'email'=>'required|email|unique:users'
);
$messsages = array(
'email.required'=>'The User Email must be a valid email address'
);
$validator = Validator::make(Input::all(), $rules, $messsages);
Laravel has a built-in validation for email addresses, and it just so happens that the examples directly solve your specific needs too.
You will need to look into using the email validator and adding custom error messages, both are documented in detail in the linked documentation.
However, I've gone ahead and combined the two solutions directly from the linked resource to solve your needs:
$validator = Validator::make($request->all(), [
'email' => 'required|email|unique:users',
], [
'email.required' => 'The User Email must be a valid email address.'
)];
Hello I setup mailgun correctly. and did form contact us.
To send the message to my email by this code
public function send_contact_us()
{
$data = array(
'name' => Request::get('name'),'email'=>Request::get('email'),'subject'=> Request::get('subject'));
$client_m=Request::get('message');
$data_message=array('message_c'=>$client_m);
echo "we above MAIL";
Mail::send('emails.message',$data_message, function ($message)use ($data) {
$message->from($data['email'], 'E-SHOPPER');
$message->to("azharnabil013#yahoo.com")->subject($data['subject']);
});
return view('contact_us', array('title' => 'Welcome', 'description' => '', 'page' => 'contact_us','subscribe'=>'','sent'=>"Message has been sent successfuly"));
}
The code run correctly and this page display
But when I check my email I didn't find any message
I don't know why this problem .please, anyone help me.
I am trying to subscribe user to mailchimp list, like this
$MailChimp = new MailChimp($apikey);
$result = $MailChimp->post('lists/'.$list.'/members', array(
'email_address' => $email,
'status' => 'subscribed',
'send_welcome' => true,
'double_optin' => false
));
Email was subscribed but no Welcome Email was sending to user. I turn on "Send a final welcome email" in mailchimp settings for this list. But it does not work. Please give me an advice
If you check the documentation here the request body parameter no longer accepting that parameter. It was there on API 2.0.