Hw to track email with sendgrid api? - email

I'm trying to track an email using sendGrid Webhook event notifier API.
I configured the apps: clicktrack, opentrack & eventnotify to true,
I created a POSTURL using RequestPin,
I activated the event notification from mail settings in my dashboard & I checked all the events, when I press the testYourIntegration button, I get the example post request to the created url.
I used this code as described in the official documentation:
string apikey = "......."
sg = sendgrid.SendGridAPIClient(apikey=os.environ.get( apikey ))
to_email = Email("....#gmail.com")
from_email =Email ("....")
subject= '...'
content=Content('..')
mail =Mail(...)
....
to send the mails & it works fine, & I get the email.
Now when I open the email sent by code, I don't get the notification in the URL,
Am I missing something?

It was a config issue, I retried the steps above & they worked fine, not sure what went wrong the first time

Related

Mail stay in queue when i use Sendgrid in symfony6

I have set my Sendgrid single sender and validate it ( status = verified).
I use SMTP, create my key that i paste in my code (.env file of my app):
MAILER_DSN=sendgrid+smtp://#default
Then i try to test integration in Sendgrid by clicking on button and refresh my localhost/ page (of course the controller's route is "/" and it contains the code using mailer to send a mail as explain in mailer documentation).
On my vue i don't have error code but mail stay in queue status...
Here the screenshot taken of the profiler:
Can someone tell me why my mail stay queued?
Of course the From email address is mine ( the verified one) and the To is anotherone of mine.
Maybe i have to configure something in my outlook mail (the From one) ?
Sendgrid never match the verification, it stay in checking status until message :
Hmm, we haven't seen your email yet.
Please check your code, run it again, then click "Retry".
Thanks for reply,
Regards,
In your question you said that your MAILER_DSN environment variable is set to:
MAILER_DSN=sendgrid+smtp://#default
That is missing your API Key though. You need to create an API key in the SendGrid dashboard and then add the API key to the MAILER_DSN variable, between the // and the #default like this:
MAILER_DSN=sendgrid+smtp://API_KEY#default
One other thing, ensure that you have installed the SendGrid transport with this command:
composer require symfony/sendgrid-mailer
Yes, thanks you a lot for reply.
Of course all was set as you notify me.
I now have fix my issue, in fact the problem for me with the mail that remains in queued is that the messenger was installed so in asynchronous by default.
I had to add the option message_bus: false in my config/packages/mailer.yaml file not to have the asynchronous option used.
Hopefully this is useful for some people.
add the option message_bus: false in my config/packages/mailer.yaml:
framework:
mailer:
dsn: '%env(MAILER_DSN)%'
message_bus: false

How to retrieve the remote Ip address for a Contact Form 7 submission?

I am using Contact Form 7 to collect data and send it through the CF7 to API Plugin.
For security reasons, I receive the data via email through the [wpcf7.remote_ip] tag, which I insert in the email field as per the guide.
Screen of The Email Body:
But when I try to send the same data via API through "CF7 to API", the value is empty.
Screen of the CF7 to API setup:
Where am I wrong?
Screen of the CF7 to API log:
wpcf7.remote_ip is only valid in an email template because it is created/populated by the CF7 plugin when the notification mail is being processed. You will need to create your own hidden field on the form when the page is loaded which you can then use in your API listing,
add_filter('wpcf7_form_hidden_fields','add_hidden_ip_field');
function add_hidden_ip_field($fields){
$fields['remote_ip'] = ... //get the remote IP
return $fields;
}
NOTE: to get the request remote IP, see this answer
You can then use the field remote_ip in your API

Email aren't been sent in Aldryn forms, even though email backend is configured

I'm using Aldryn forms to submit contact page. In aldryn forms when the contact form is submitted it can be seen in the admin panel.
Including this, I need to receive email notifications.
As I've already worked on a few email notification projects in Django.
I've provided the relevant code for the email-backend config.
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'abc#gmail.com'
EMAIL_HOST_PASSWORD = 'xxx'
EMAIL_PORT = '587'
EMAIL_USE_TLS = True
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
When the contact form is submitted I need to receive an email in abc#gmail.com
please let me know if anything I'm missing out or wrongly configured.
I've resolved the issue after filling "Recipients" section in "Email notifications" inside settings of "Form" plugin (aldryn-forms plugin of Djangocms in my case). Settings are correct - work for me.

Which URL made the request to my Google Apps Script?

How can I determine the source URL of a GET or POST request sent to a Google Apps Script web application?
I am making a (PayPal IPN) listener script and would like to be able to distinguish weather the request came from a the test environment (sandbox) or from the live environment.
The origin of the request to the listener determines the response from the script. The listener has to send a response back to PayPal and depending on which environment the request came from, the response needs to go back either to the sandbox server or to the live server.
I am hoping to distinguish between requests from sandbox.paypal.com or www.paypal.com, in my Google Apps Script.
To work around this requirement, I have set it manually for now:
if (PPRunMode == 'test') {//in testmode send response to sandbox site
PPUrlBase = "https://www.sandbox.paypal.com/cgi-bin/webscr";
}
else {//url for live website
PPUrlBase = "https://www.paypal.com/cgi-bin/webscr";
}
But was wondering if this can be determined automatically.
Unfortunately, no request-source information is provided to your Google Apps Script web application, so there is no direct way to determine where a request came from.
You do have the ability to provide parameters to your web app, though, so you could have the code in the sandboxed environment use that to indicate a test condition.
For example, this URL could be used by the sandboxed code for a GET request:
https://script.google.com/macros/s/---SCRIPT-ID---/exec?test=true
^^^^^^^^^^
In the doGet(e) function, you would handle the parameter like this:
function doGet(e) {
if (e.parameter.test) { //in testmode send response to sandbox site
PPUrlBase = "https://www.sandbox.paypal.com/cgi-bin/webscr";
}
else {//url for live website
PPUrlBase = "https://www.paypal.com/cgi-bin/webscr";
}
...
}
For a POST request, the solution is similar. See URL parameters in the Web Apps and Google Sites Gadgets guide for details.
If you publish your Google App Script you get two urls :
https://script.google.com/macros/s/AKfycbxsCNyssA0dzMMmsNip3DW66hiJ62ks_F1yYUn0SDu073S2dOw/exec
https://script.google.com/macros/s/AKfycbxzpvZ9e9_vzs3d6Q0ky_RHLoYDruCl-6Xm8D6YmI4/dev
You can notice the difference, not sure if that is what you are pointing to

Liferay: how do I add verication URL to new account e-mail

(Using Liferay 6.1.0-CE-GA1.) I have written my own user registration portlet. When I UserLocalServiceUtil.addUser(...), the sendEmail parameter is true and, indeed, it sends the Account Verification Notification.
I've modified that notification by adding this line to it:
Please verify your email address for [$PORTAL_URL$] by clicking this link: [$EMAIL_VERIFICATION_URL$].
Unfortunately the e-mail it sends contains this line, literally:
Please verify your email address for xxx by clicking this link: [$EMAIL_VERIFICATION_URL$].
Is there any way to make this work? I want to send one e-mail with the verification code. My program flow requires it.
Thank you.
You should use this after you added the account in the action
ServiceContext serv = ServiceContextFactory.getInstance(request);
UserLocalServiceUtil.sendEmailAddressVerification(user1, user1.getEmailAddress(), serv);