E-mail activation not working with php mail

Go to your Control Panel, then on Programs & Functionalities, then click on “Enable or disable Windows functionalities”, tick “Telnet” and click OK. Then wait a bit and Telnet is installed.

thank you so much! I got it working now but still can’t telnet…

I didn’t know that the recaptcha can cause issue as well because none of the video tutorials did mention about this…

The CAPTCHA request on any login sometimes prohibits the access to the account via some clients like PHPMailer and you need to access firstly the account via another device to complete then the CAPTCHA. With the DisplayUnlockCaptcha Page on the Google Accounts domain, just click to access the Google account, close the Page and try to access the Google account again.

I guess is phpmailer reliable? Will other people be able to receive the mail and can anyone sign up with any email providers including hotmail?

Yes, PHPMailer is reliable, other people will be able to receive the email (if the template is configured perfectly) and anyone can signup with all many providers (even Outlook), even if Outlook puts emails sent through some other email folder in the Spam the first time, so go to the Spam folder and find the Message, then trust messages from that email and you should receive messages directly from the mail inbox!

The other problem is that for this line of code… it should say…$mail->SetFrom(‘[email protected]’);

For some reason, it is still showing my actual gmail address and not [email protected]

You can’t do no-reply emails with Gmail. You must use the one you used to Sign in with SMTP.

1 Like

I have done another thing in my mail function where I could save a copy of the mail to a text file with fopen, is this the same method with phpmailer? how would I do that with phpmailer to make a new file where the user could save his or her information into it then I guess I would need to use $email->addAttachment();?

I didn’t test the saving in the TXT file with PHPMailer, so I can’t tell you.

Do you know roughly how we can save it into a text file because I really need that working for my phpmailer.

We could use fwrite() to write something into a HTML file that exists, and that can be opened by fopen() with the mode “w+”, like so:
...
$file = fopen("yourfile.html", "w+");
echo fwrite($file,"youremailmessage");
fclose($file);
$mail->addAttachment("yourfile.html"); // if you want to attach the HTML file with the code
...
The suspension periods indicate the continuation of the file, yourfile.html indicates the file of the email (assuming that it exists) and youremailmessage indicates the message in HTML.

thanks how would I create a new file if it doesn’t exit? I can’t remember but I don’t think it is +w is it?

You could use the Monsta FTP; create it on the htdocs and call it with “yourfile.html”, then close the editor.
It’s not +w, it’s w+, my bad; I’ve checked it on W3Schools.

Will w+ create a new file? Basically, I would like to create a file based on the username when they register my site. The variables are $uid, which is the username and I would like to put the $mail->body inside the file, would I do something like this:?

$file = fopen(“yourfile.html”, “+w”);

echo fwrite($file,$mail->Body);

fclose($file);

$mail->addAttachment(“yourfile.html”)

But I am not sure where to add the $uid?

w+ does not create a new file, it only uses read and write permissions; the same goes with r+. You can copy the $mail->Body variable contents and create a new variable with that. Example with my contact form HTML message (in Italian):
$uid = "Username: " . $username . " &lt;" . $email . "&gt; <br /> Messaggio: " . $message . " <br /><br /><br /><div style='text-align:right'>Inviato dal form di Ergastolator Website</div>";,
knowing that $username is $_POST["username"], $email is $_POST['email'] and $message is $_POST["message"], then overwrite the other code with this:
$file = fopen("yourfile.html", "w+");
echo fwrite($file,$uid);
fclose($file);
$mail->addAttachment("yourfile.html"); // if you want to attach the HTML file with the code,
where yourfile.html is overwritten by $username . ".html".

Can I do something like the following and can’t I use $mail->Body as it is easier? Can I create a $newfile like this and how would I tell it where to save? I like to create another folder for it, maybe a folder called invoice?

$date = date(“Y-m-d”);

$newfile = PrimerLevelAccount".$uid.“”.$date.";

$file = fopen($newfile, “+w”);

echo fwrite($file,$mail->Body);

fclose($file);

$mail->addAttachment(“yourfile.html”)

I think my $newfile concatenation is wrong…

You can use it. W3Schools says that fopen will create the file if it doesn’t exist. But $newfile doesn’t have the correct syntax. Let me show you how to fix it:
$date = date("dmY");
$newfile = "PrimerLevelAccount_".$uid."_".$date.".html";
$file = fopen($newfile, "+w");
echo fwrite($file, $mail->Body);
fclose($file);
$mail->addAttachment($newfile);

$uid should contain the username contained in a input form with the name of uid, like $_POST["uid"].

thanks and must I always need to use the underscore as follows to add more variables in this case?

$newfile = “PrimerLevelAccount_”.$uid.“_”.$date.“.html”; and where did you get the html part? Must I also need the _ before $uid?

The underscores between the double quotes, not just underscores. I did add the “.html” part before, because it will be a html file on the $newfile variable.
On $uid I defined the HTML part with my code, present on mailfunctions/process.php inside of the $mail->Body variable defined, but you must use the POST method to use the input form with name of uid. You must also need the “_” before $uid, because like so the name of the file is easier to read.