A PHPMailer based mailing function with simplified email capabilities utilizing mysql for multi email host/account capabilities
-
Ability to use multiple existing mail systems like
Gmail
Yahoo
Rediffmail
etc.
-
Ability to define host/account switch limits (Switch email sender after one limit of that particular account is reached)
-
Single dashboard for setting/updating mail accounts/hosts.
-
Easy Integartion into existing systems
Refer to account_for_emails.sql
- Download the latest source zip and extract it in your
web root
- Import
account_for_emails.sql
in your database - Edit
conn.php
to fit your needs. - Include
mailer.php
in required locations/files/scripts and usesendMail()
function.
<?php
include "mailer.php";
@$toEmail = $_POST['email'];
@$toName = $_POST['name'];
@$message = $_POST['message'];
@$subject = $_POST['subject'];
@$replyToEmailAddress = $_POST['replyToEmailAddress'];
@$replyToName = $_POST['replyToName'];
if(!empty($toEmail)){
echo "Result: ";
if(sendMail($replyToEmailAddress, $replyToName, $toEmail, $toName, $subject, $message, $message, "")) {
echo "Email message sent.";
} else {
echo "<br><hr>Failed to send email.";
}
}
?>
$replyToEmailAddress: The email address that the recipient will reply to
$replyToName: The name that the recipient will see for the reply to address
$recieverEmailAddress: The email address of the recipient
$recieverName: The name that the recipient
$emailSubject: The subject of the email
$emailBody: The body of the email (HTML)
$alternateBody: The body of the email in Text format
$attachmentsPaths: An key-value pairs of fileNames to the filePaths to be attached in mail
Please refer to sample.php
Before using this function be informed that, I am not sure if it is formally approved by Google to use its SMTP server to send email in this way. I do not see any information prohibiting it either.
- Disable two-factor authentication (This step is applicable, only if you have already enabled it.)
- Allow
Less secure app access
by loging in to your Gmail account and then going to page https://myaccount.google.com/lesssecureapps and Turning this optionOn
.
- Disable two-factor authentication (This step is applicable, only if you have already enabled it.)
- Login to your Yahoo account and then go to page https://login.yahoo.com/account/security
- Scroll down to the section
Other ways to sign in > App password
and clickGenerate and manage app passwords
- Then enter some name in
Enter your App name
field and then clickGenerate Password
. - Then a password will appear on screen, use this password for yahoo account
password
in DB/Dashboard.
- Gmail
Host:
smtp.gmail.com
Port:
587
SMTPSecure:
tls
email_limit:
500
- Yahoo mail
Host:
smtp.mail.yahoo.com
Port:
587
SMTPSecure:
tls
email_limit:
500