I would like to know how to send email to multiple recipients by phpmailer while the email address is input by the user at the front-end rather than hard-code the address at the back-end.
Please kindly advise.
Thanks,
Wayne
Passing the emails and names to your script, and then simply calling the AddAddress method when you're processing the incoming information would do it.
It isn't clear from your question whether you want to have multiple or single recipients.. it's a little contradictory. Here's a basic example for multiple recipients with their names and emails in an array:
require 'class.phpmailer.php';
$mail = new PHPMailer;
/*
set up your email here...
*/
foreach ($recipients as $email => $name) {
$mail->AddAddress($email, $name);
}
/*
Then send your email..
*/
What have you tried?
Related
I want to send newsletters to multiple users, but when I try my code, the emails can be seen by everyone. And if I send it using looping, I'm afraid it will take a long time because there are many users. Is there a good solution to send multiple emails?
This is my code (I use SMTP):
await Mail.send('newsletter', data, (message) => {
message
.from('newsletter#web.com', 'Admin')
.subject('New Events Notification')
.to(emails) // array consist of multiple emails
})
You can use the sendLater method to send multiple emails. The Adonis js uses the memory queue inside this method. So it will not block your HTTP request.
After replacing the method your code will look like this .
await Mail.sendLater('newsletter', data, (message) => {
message
.from('newsletter#web.com', 'Admin')
.subject('New Events Notification')
.to(emails) // array consist of multiple emails
})
Now you can add your loop and Adonis js will send email in background.
I'm using the DocuSign REST API to automate document signing. I use the sender view to allow my clients to place signing tabs on their documents and ultimately send them.
However, I'm running into a problem where the client, for whatever reason, needs to start over in our workflow, and so abandons the embed without saving it and contacting us to restart the process.
Normally, we'd call Update to mark the Envelope as voided and then create a new one, but because the client didn't exit the embed properly, the Envelope is still marked as locked.
I thought the Delete Lock endpoint would allow us to remove the lock so that we could edit the envelope, but it's returning an error message saying that we can't delete the lock as we weren't the ones who put it there.
Given that the same credentials were used for both the embed window and the delete lock call, why does DocuSign treat us like two different users? And is there a way to get around the lock?
This might help some folks in the future.
"by appending a lockToken parameter to the view URL, you can give your
integration control over the envelope lock, enabling it to make
changes to the envelope without having to wait for the DocuSign token
to expire."
http://m.mmffs.com/the-trenches-whos-locking-my-envelopes.html
The article shows how to accomplish this using the API directly. In the code snippet below, this is how you would do it going against the DocuSign Nuget package.
var lockInfo = envelopesApi.CreateLock(accountID, envelopeID, new LockRequest()
{
LockedByApp = "[Your App]",
LockType = "edit"
});
existingViewUrl += "&lockToken={lockInfo.LockToken}";
Note, the third LockRequest parameter is required for this to work even though it is not required by the CreateLock method. Credit to Inbar Gazit - Error trying to add a document to envelope and getting a user lock error message
Now, the normal DeleteLock method will work.
try
{
var lockInfo = envelopesApi.GetLock(accountId, envelopeID);
if (lockInfo?.LockDurationInSeconds?.Length > 0)
{
envelopesApi.ApiClient.Configuration.AddDefaultHeader("X-DocuSign-Edit", $"{{\"lockToken\":\"{lockInfo.LockToken}\"}}");
envelopesApi.DeleteLock(accountId, envelopeID);
}
}
catch(ApiException e)
{
// Not locked.
}
Lock is done by NDSE not your credentials, solution is to wait for sometime and lock will be released by NDSE or you have to redirect user to same screen again and the user needs to select Save and Close instead of Discard Changes. Once user selects Discard Changes then envelope is moved to Deleted folder.
You can try code below:
var config = new Configuration(new ApiClient(basePath));
config.AddDefaultHeader("Authorization", "Bearer " + accessToken);
var envelopesApi = new EnvelopesApi(config);
try
{
// this line will throw error if envelope is not locked, so handle it using try & catch block
LockInformation lockInfo = envelopesApi.GetLock(accountId, envelopeId);
// check if this app locked it
if (lockInfo?.LockDurationInSeconds?.Length > 0)
{
// add a header with the LockToken to ensure this app has the right to unlock
string LockHeader = $"{{\"lockToken\":\"{lockInfo.LockToken}\"}}";
envelopesApi.Configuration.AddDefaultHeader("X-DocuSign-Edit", LockHeader);
envelopesApi.DeleteLock(accountId, envelopeId);
}
}
catch (ApiException exp)
{
// Do Whatever you want to do
}
I am using mail-listener-2 and node.js to receive emails. I have it all setup doing what I want except for one thing.
I can not figure out how to get just the text of the current message. This is what I mean.
1. Send an email in my application with a unique id in the subject.
2. User receives email in inbox and replies.
3. Mail-Listener-2 grabs the email reply and saves it under the unique id.
Code:
mailListener.on("mail", function(mail, seqno, attributes){
var body = mail.text
});
Now when step 3 occurs, it's grabbing the entire thread message. Instead of just the message the user sent. Meaning, my original message plus the users new message is included in the reply.
Is there a way to grab just the users reply? Or do I just need to do something like putting a line in the message and then parse everything before the line?
Try this one:
mailListener.on("mail", function(mail, seqno, attributes){
text:mail.text
});
I'm using Mandrill to send emails, and I defined $m in itinializer:
$m = Mandrill::API.new 'XmylongkeygoeshereTg'
I need to test a function that send an email, so I need to stub the $m.messages.send method somehow on that existing object. I read that stub_chain is a messy way to achieve that, but even that didn't work. Another way I tried was with allow($m.messages).to like that:
it "sends emails to a group" do
# stub Mandril's email sending, so no actual emails will be sent.
allow($m.messages).to receive(:send) { nil }
expect(subject.my_sending_emails_method).to be_true
end
While there's no error, there's also no effect of stubbing - the emails are still being sent.
Please suggest how to stub it?
There might be more than one answer, but what I found working is:
allow($m).to receive_message_chain(:messages, :send) { nil }
I've set up my mailto links so that they open Gmail.
// you can code a url like this to push things into gmail
https://mail.google.com/mail/?view=cm&fs=1&tf=1&to=user#example.com
I understand there are several other variables:
&su= // email subject
&body= // body text
&disablechatbrowsercheck=1 // pretty self explanatory
The thing is I can't find a list anywhere with the possible ones.
Has anyone composed such a thing or found such a list.
Edit: You can now resort to classic mailto links to pass subject and body params:
email here
why bother doing that ? the mailto link will open the default mail client you have installed
i think having gmail notifier installed is enough
and that will be better to users with no gmail.
see here Making Gmail your default mail application or this Make mailto: links open in gmail
if not i found this example from here:
https://mail.google.com/mail?view=cm&tf=0" +
(emailTo ? ("&to=" + emailTo) : "") +
(emailCC ? ("&cc=" + emailCC) : "") +
(emailSubject ? ("&su=" + emailSubject) : "") +
(emailBody ? ("&body=" + emailBody) : "");
The example URLs for standard gmail, above, return a google error.
The February 2014 post to thread 2583928 recommends replacing view=cm&fs=1&tf=1 with &v=b&cs=wh.