PHPMailer is the library for PHP to support full-featured email creation and email sending functionality.
I am trying to put all the PHPMailer functionality information, download links and other helpful links in this blog to save the time of developers to get the code and all issues resolved in one place.
"require": {
"php": ">=5.5.9",
"phpmailer/phpmailer": "^6.0"
},
<?php
/*******
PROGRAM: Create a simple random password in PHP which will be unbreakable
******/
// STEP 1. Define the password length
$password_length=10;
// STEP 2. DEFINE AND CALL PASSOWRD GENERATOR FUNCTION
function unbreakable_password($pass_len=8) // default value, if length is not provided
{
// all the characters which you want to use for password creation
$all_chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%abcdefghijklmnopqrstuvwxyz';
//shuffle all chars..
$shuffled_chars= str_shuffle( $all_chars);
//get first $pass_lennumber of characters from shuffled string as a password
$password = substr( $shuffled_chars, 0, $pass_len);
return $password;
}
echo $unbreakable_password=unbreakable_password($password_length);
?>
SMTPDebug –
If you are having problems connecting or sending emails through your SMTP server, the SMTPDebug provides more information about the processing/errors taking place.
Numbers assigned to SMTPDebug property are the debugging levels explained as below,
$mail->SMTPDebug = 0;
– Disable debugging
$mail->SMTPDebug = 1;
– Output messages sent by the client.
$mail->SMTPDebug = 2;
– Output messages sent by the client
– and responses received from the server (this is the most useful setting).
$mail->SMTPDebug = 3;
– Output messages sent by the client
– and responses received from the server (this is the most useful setting)
– and more information about the initial connection – this level can help diagnose STARTTLS failures.
$mail->SMTPDebug = 3;
– Output messages sent by the client
– and responses received from the server (this is the most useful setting)
– and more information about the initial connection – this level can help diagnose STARTTLS failures.
– and even lower-level information, very verbose.Note: You don’t need to use levels above 2 unless you’re having trouble connecting at all – it will just make output more verbose and more difficult to read.
isSMTP() – Tell PHPMailer to use SMTP
SMTPSecure – Set the encryption system to use – ssl or tls
SMTPAuth– set whether to use SMTP authentication (true/false)
Host – Name of local or non-local mail server hostname
Port- Set the SMTP port number to connect to (587 for authenticated TLS)
setFrom() – Set who the mail is to be sent from
addAddress() – Set who the mail is to be sent to (Name of recipient is Optional)
addReplyTo() – Set an alternative email address to whom recipient can reply
addAttachment – file attachments.
Exanmples:
$mail->addAttachment(‘/var/tmp/file.tar.gz’); // Add attachments
$mail->addAttachment(‘/tmp/image.jpg’, ‘new.jpg’); // Optional name
setLanguage() – PHPMailer provides Error messages in 47 languages!
Example:
$mail->setLanguage(‘fr’, ‘/optional/path/to/language/directory/’);
Default is English.
Priority – Email priority (1 = High, 3 = Normal, 5 = low)
MsgHTML– Creates the email body from HTML content.
AltBody – Replace the plain text body with one created manually
WordWrap– Sets word wrapping on the body of the message to a given number of characters.
Comment below if you have any doubts…
Hi there,
I wanted to stop by and give my genuine feedback on your website. I really enjoyed to read your content, I think it’s interesting and very well written. I’ve been on your website for an hour or so and very enjoyed it.
I didn’t find your Instagram page though, do you have one?
Best,
Yalla
Hello Yalla,
Here is my updated Instagram page link: https://www.instagram.com/aanand_lagad/
Comments