Sending mail to the Professor for PhD, after seeing his tweet A professor tweeted that he has a PhD position in his lab. I am trying to write a mail regarding that. How should I express that where did I find the advertisement?

Is it right to start mail like this:

Dear Prof. ZZZ,

I am writing to apply for the PhD position which was posted on your twitter.


Or should I write something else?
That is perfectly fine.  The professor chose to use twitter as a medium of announcing the position.  They are expecting responses to that advertisement.  It's always a good idea to explain how you heard about the position.  Your email does all of those things.