Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* You need to download php-mailer class
- https://github.com/PHPMailer/PHPMailer */
- print_r(send_mail('vinodyadavhhh4@gmail.com','Lorem Ipsum','anything....'));
- function send_mail($email, $recipient_name, $message='')
- {
- require("phpmailer/class.phpmailer.php");
- require("phpmailer/class.smtp.php");
- $mail = new PHPMailer();
- $mail->CharSet="utf-8";
- $mail->IsSMTP(); // set mailer to use SMTP
- $mail->Host = "mail.example.com"; // specify main and backup server
- $mail->SMTPAuth = true; // turn on SMTP authentication
- $mail->Username = "myusername"; // SMTP username
- $mail->Password = "p@ssw0rd"; // SMTP password
- $mail->From = "me@walalang.com";
- $mail->FromName = "System-Ad";
- $mail->AddAddress($email, $recipient_name);
- $mail->WordWrap = 50; // set word wrap to 50 characters
- $mail->IsHTML(true); // set email format to HTML (true) or plain text (false)
- $mail->Subject = "This is a Sampleenter code here Email";
- $mail->Body = $message;
- $mail->AltBody = "This is the body in plain text for non-HTML mail clients";
- $mail->AddEmbeddedImage('images/logo.png', 'logo', 'logo.png');
- $mail->addAttachment('files/file.xlsx');
- if(!$mail->Send())
- {
- echo "Message could not be sent. <p>";
- echo "Mailer Error: " . $mail->ErrorInfo;
- exit;
- }
- echo "Message has been sent";
- }
Add Comment
Please, Sign In to add comment