Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all 29762 articles
Browse latest View live

laravel, sending email takes 1 minutes using 365 office mail - too slow

$
0
0

I'm usig 365 office email service from godaddy, as before I used cpanel email account, I talked to godaddy about the delay(exactly 60 seconds) they adviced me to buy 365 office email, I did and what!! the same issue, it takes one minute, meanwhile using gmail account in localhost takes millisecondes please help me, I changed sendmail to stmp but the same issue

mail config:

'driver' => env('MAIL_DRIVER', 'sendmail'),
  'host' => env('MAIL_HOST', 'localhost'),
  'port' => env('MAIL_PORT', 587),
   'from' => ['address' => '*****', 'name' => '***'],
     'encryption' => 'tls',
     'username' => env('MAIL_USERNAME'),
    'password' => env('MAIL_PASSWORD'),
     'sendmail' => '/usr/sbin/sendmail -t',
    'pretend' => false,

Env:

   MAIL_DRIVER=sendmail
    MAIL_HOST=smtp.office365.com
      MAIL_PORT=587
      MAIL_USERNAME=*****
     MAIL_PASSWORD=******
    MAIL_ENCRYPTION=tls

SMTP Error could not authenticate and SMTP Error failed to connect to server(0)

$
0
0

I'm getting this SMTP error when using the newest PHPMailer release:

SMTP Error: Could not authenticate.

I've tried using SSL instead of TLS with port number 465. OpenSSL is already loaded in the config file, and I've looked through the troubleshooting guide none of this has made a difference, what exactly is wrong with my code? One thing I'm not sure of is including the OAuth2 provider class with this :

use League\OAuth2\Client\Provider\Google;

There's no file path for that, should I change this? Also, when I change encryption to $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; and now I get this : SMTP ERROR: Failed to connect to server: (0).

Here's the code:

    class gmail_xoauth

    {
        public static function sendMail($subject,$body,$address)
        {


    $mail = new PHPMailer();
    $mail->isSMTP();

    $mail->SMTPDebug = SMTP::DEBUG_CLIENT;
    $mail->Host = 'smtp.gmail.com';
    $mail->Port = 587;
        $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
    $mail->SMTPAuth = true;
    $mail->AuthType = 'XOAUTH2';

    //Fill in authentication details here
    //Either the gmail account owner, or the user that gave consent
    $email = 'myemail@gmail.com';
    $clientId = 'clientid';
    $clientSecret = 'clientSecret';
    //Obtained by configuring and running get_oauth_token.php
    //after setting up an app in Google Developer Console.
    $refreshToken = 'refreshToken';
    //Create a new OAuth2 provider instance
    $provider = new Google(
        [
            'clientId' => $clientId,
            'clientSecret' => $clientSecret,
        ]
    );
    //Pass the OAuth provider instance to PHPMailer
    $mail->setOAuth(
        new OAuth(
            [
                'provider' => $provider,
                'clientId' => $clientId,
                'clientSecret' => $clientSecret,
                'refreshToken' => $refreshToken,
                'username' => $email,
            ]
        )
    );
    //Set who the message is to be sent from
    //For gmail, this generally needs to be the same as the user you logged in as
    $mail->setFrom($email, 'me');
    //Set who the message is to be sent to
    $mail->addAddress($address, 'John Doe');
    //Set the subject line
    $mail->Subject = $subject;
    //Read an HTML message body from an external file, convert referenced images to embedded,
    //convert HTML into a basic plain-text alternative body
    $mail->CharSet = PHPMailer::CHARSET_UTF8;
    $mail->msgHTML(file_get_contents('PHPMailer/PHPMailer-master/examples/contentsutf8.html'), __DIR__);
    //Replace the plain text body with one created manually
    $mail->AltBody = 'This is a plain-text message body';
    //Attach an image file

    $mail->addAttachment('PHPMailer/PHPMailer-master/examples/images/phpmailer_mini.png');
    //send the message, check for errors
    if (!$mail->send()) {
        echo 'Mailer Error: '. $mail->ErrorInfo;
    } else {
        echo 'Message sent!';
    }
    }
    }

This is the full error

    SERVER -> CLIENT: 220 smtp.gmail.com ESMTP w67sm7347917yww.16 - gsmtp
    CLIENT -> SERVER: EHLO localhost
    SERVER -> CLIENT: 250-smtp.gmail.com at your service, [108.203.6.59]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
    CLIENT -> SERVER: STARTTLS
    SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
    CLIENT -> SERVER: EHLO localhost
    SERVER -> CLIENT: 250-smtp.gmail.com at your service, [108.203.6.59]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
    SMTP Error: Could not authenticate.
    CLIENT -> SERVER: QUIT
    SERVER -> CLIENT: 221 2.0.0 closing connection w67sm7347917yww.16 - gsmtp
    SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
    Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/TroubleshootingEmail sent!

Saving to .msg file in Python, or alternatively, sending mail to the file system

$
0
0

I'm using the emails library to send mail, but I also need to save it as .msg file. I've done some research and also read the msg format specification and stumbled upon this SO answer that shows how to send mail to the file system in C# and I was wondering if it was possible in Python as well.

VBA code in outlook, to open an MS Excel file in whenever an email is received by a specific person and subject line [closed]

$
0
0

I want VBA coding in outlook, to open an MS Excel file in a particular location in my hard drive, whenever an email is received by a specific person, with a specific subject line. I have tried it, However, the MS Excel file is getting open with every new email. I am not able to put a condition of specific sender / sender's email id and specific subject line.

Send HTML report and Cucumber reports through Jenkins to email

$
0
0

I m looking for sending HTML reports through jenkins to Outlook. I tried all the possible ways like installing Editable email notification and Cucumber reports but could not succeed. Could you please let me know what are the config changes which i need to make in jenkins to get HTML reports to my mail

What's causing SMTP-Server to give "500 5.5.2 Error: bad syntax"?

$
0
0

I am writing a tool to send mails. Unfortunately after the DATA-Command has been processed, the server responds with an error. I can stare at the msg as long as I want, I don't see anything that jumps out. But maybe I'm missing the obvious. Here's a complete log of that session: (CRLF causes blank line in the log, but for authenticity I left it in)

cmd="AUTH LOGIN"
rc=" 0  CLT00000004  Block  334 VXNlcm5hbWU6    

 "                                              
cmd="***"
rc=" 0  CLT00000004  Block  334 UGFzc3dvcmQ6    

 "                                              
cmd="***"
rc=" 0  CLT00000004  Block  235 2.7.0 Authentication successful    

 "                                                                 
cmd="NOOP"
rc=" 0  CLT00000004  Block  250 2.0.0 Ok    

 "                                          
cmd="MAIL FROM: <***>"
rc=" 0  CLT00000004  Block  250 2.1.0 Ok    

 "                                          
cmd="RCPT TO: <***>"
rc=" 0  CLT00000004  Block  250 2.1.5 Ok    

 "                                          
cmd="RCPT TO: <***>"
rc=" 0  CLT00000004  Block  250 2.1.5 Ok    

 "                                          
cmd="DATA"
rc=" 0  CLT00000004  Block  354 End data with <CR><LF>.<CR><LF>    

 "                                                                 
cmd="Subject: [TEST] Here it is

MIME-Version:1.0

Reply-To:<***>

From:<***>

Date: Fri, 29 Nov 2019 10:05:02 +0100

Content-Type: text/plain; charset=utf-8; format=flowed

Content-Transfer-Encoding:7bit



Contributed by: MBaas <***>

first line





and more text
with a lone "." @ EOM




..



.

"
rc=" 0  CLT00000004  Block  250 2.0.0 Ok: queued as 4668A16C05CB                                 

500 5.5.2 Error: bad syntax                                                                      

 "

email form is refreshing page

$
0
0

Hello all I am a newbie here and have been training on html and minimal php coding, i am trying to make a quotation form which i have managed to complete but i am really struggling with the php side of things. i have borrowed some coding online and tried to make it adapt with my form but it keeps refreshing the page, please if there is anyone out there that can help please get back to me thankyou here is my code

<?php
/*
This first bit sets the email address that you want the form to be submitted to.
You will need to change this value to a valid email address that you can access.
*/
$webmaster_email = "jhugill94@gmail.com";

/*
This bit sets the URLs of the supporting pages.
If you change the names of any of the pages, you will need to change the values here.
*/
$feedback_page = "/Quotation.html";
$error_page = "/error_message.html";
$thankyou_page = "/thank_you.html";

/*
This next bit loads the form field data into variables.
If you add a form field, you will need to add it here.
*/
$senderFirst = $_REQUEST['senderFirst'] ;
$senderLast = $_REQUEST['senderLast'] ;
$senderNumber = $_REQUEST['senderNumber'] ;
$senderEmail = $_REQUEST['senderEmail'] ;
$issue_discription = $_REQUEST['issue_discription'] ;
$car_make = $_REQUEST['car_make'] ;
$car_model = $_REQUEST['car_model'] ;
$fuel_type = $_REQUEST['fuel_type'] ;
$engine_size = $_REQUEST['engine_size'] ;
$image_upload = $_REQUEST['image_upload'] ;
$msg = 
"First Name: " . $senderFirst . "\r\n" . 
"Sur Name: " . $senderLast . "\r\n" . 
"Contact Number: " . $senderNumber . "\r\n" . 
"Email: " . $senderEmail . "\r\n" . 
"Issue Discription: " . $issue_discription ;
"car_make: " . $car_make ;
"car_model: " . $car_model ;
"fuel_type: " . $fuel_type ;
"engine_size: " . $engine_size ;
"image_upload: " . $image_upload ;

/*
The following function checks for email injection.
Specifically, it checks for carriage returns - typically used by spammers to inject a CC list.
*/
function isInjected($str) {
    $injections = array('(\n+)',
    '(\r+)',
    '(\t+)',
    '(%0A+)',
    '(%0D+)',
    '(%08+)',
    '(%09+)'
    );
    $inject = join('|', $injections);
    $inject = "/$inject/i";
    if(preg_match($inject,$str)) {
        return true;
    }
    else {
        return false;
    }
}

// If the user tries to access this script directly, redirect them to the feedback form,
if (!isset($_REQUEST['email_address'])) {
header( "Location: $feedback_page" );
}

// If the form fields are empty, redirect to the error page.
elseif (empty($first_name) || empty($email_address)) {
header( "Location: $error_page" );
}

/* 
If email injection is detected, redirect to the error page.
If you add a form field, you should add it here.
*/
elseif ( isInjected($email_address) || isInjected($first_name)  || isInjected($comments) ) {
header( "Location: $error_page" );
}

// If we passed all previous tests, send the email then redirect to the thank you page.
else {

    mail( "$webmaster_email", "Feedback Form Results", $msg );

    header( "Location: $thankyou_page" );
}
?>

Type Email doesn't support selectionrange

$
0
0

I'm trying to set my cursor to the position of the beginning when I'm on focus of a text box. This is what I have:

$("ID").focus(function () {
    var input = this;
    setTimeout(function() {
        input.setSelectionRange(0, 0);
    }, 0);
});

But I get this error every time I try to load the script:

Uncaught InvalidStateError: Failed to execute 'setSelectionRange' on 'HTMLInputElement': The input element's type ('email') does not support selection.

Guess I can't use setSelectionRange on emails. So, any other solutions on how to set my cursor position in the input text box (without changing the type email)?


Laravel Imap connect() slow | reuse?

$
0
0

I am using laravel-imap to connect to my email server and get all mailboxes and messages.

I noticed that the connect() method is slow, it takes 4-5 sec.:

$start = microtime(true);

$oClient = new Client([
    'host'          => env('MAIL_HOST_IN'),
    'port'          => env('MAIL_PORT_IN'),
    'encryption'    => env('MAIL_ENCRYPTION_IN'),
    'validate_cert' => true,
    'username'      => env('MAIL_USERNAME'),
    'password'      => env('MAIL_PASSWORD'),
    'protocol'      => 'imap'
]);

// Connect to the IMAP Server
$oClient->connect(); 

\Log::info('Connect: ' . strval(microtime(true) - $start));

Thats it, there is no additional code. I also use getFolders() and loop through them to get messages. I count/get unseen messages and do more operations, but they are all fast.

I am asking this, because if I login into my mailbox through the website, the performance is much better 1-2 sec. And the operation is the same, I get the mailboxes and a count on unseen messages. So why it is slow via script?

In case it simply is like that and I cant change it, what are some possible solutions? The only idea I have right now it to reuse the connection in multple functions, so at least I connect only once.

How do I add an auto reply function to this PHP script? [duplicate]

$
0
0

This question already has an answer here:

I managed to get the form to send me mail but would like to auto respond with a thank you message.

<?php

if (isset($_POST['submit'])) {
  $name = $_POST['name'];
  $subject = "Email Confirmation";
  $mailFrom = $_POST['email'];

  $mailTo = "info@nulla.com";
  $headers = "From: ".$mailFrom;
  $txt = $name." Just Signed Up to Nulla!";

  mail($mailTo, $subject, $txt, $headers);
  header("Location: http://nulla.com/#subForm");
}

Simple way to consolidate emails into a single excel report [closed]

$
0
0

We have many different databases that send excel files as attachments to a single email address.

And my goal is to consolidate all these attachments into a single Excel file.

I am searching for a way to programmatically access the email box and consolidate all these attachments into a single excel file, that is then sent to another email address.

What kind of library or language could help achieve this in the most efficient way ? Or maybe there is already a simple program out there that does exactly this ?

How to structure DKIM headers

$
0
0

I'm working on a system that sends emails from the ground up.

I'm currently working on a DKIM signer, I know how to do it, but cannot find how to format the header and body before hashing them.

Does anyone know this? Already thanks.

Why is this HTML adding a horizontal line to Outlook Emails?

$
0
0

I'm deploying an email for a client that is pretty straight forward. But for some reason Outlook adds a horizontal line between 2 tables. I cannot for the life of me figure out why.

horizontal line example

Code in question:

<!--[if (!mso)&(!IE)]><!-->
<div style="border-top:5px solid #D9d9d9; border-left:5px solid #D9d9d9; border-bottom:5px solid #D9d9d9; border-right:5px solid #D9d9d9; padding-top:0px; padding-bottom:10px; padding-right: 0px; padding-left: 0px;">
    <!--<![endif]-->
    <div class="img-container center  autowidth  fullwidth" align="center" style="padding-right: 20px;padding-left: 20px;">
        <!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr style="line-height:0px"><td style="padding-right: 20px;padding-left: 20px;" align="center"><![endif]-->
        <div style="font-size:1px;line-height:20px">&nbsp;</div><a href="" target="_blank" tabindex="-1"> <img class="center  autowidth  fullwidth" align="center" border="0" src="" alt="Image" title="Image" style="text-decoration: none; -ms-interpolation-mode: bicubic; height: auto; border: none; width: 100%; max-width: 183px; display: block;" width="183"></a>
        <div style="font-size:1px;line-height:15px">&nbsp;</div>
        <!--[if mso]></td></tr></table><![endif]-->
    </div>
    <!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 10px; padding-left: 10px; padding-top: 10px; padding-bottom: 10px; font-family: Arial, sans-serif"><![endif]-->
    <div style="color:#555555;font-family:'Open Sans', Helvetica, Arial, sans-serif;line-height:1.2;padding-top:10px;padding-right:10px;padding-bottom:10px;padding-left:10px;">
        <div style="line-height: 1.2; font-family: 'Open Sans', Helvetica, Arial, sans-serif; font-size: 12px; color: #555555; mso-line-height-alt: 14px;">
            <p style="font-size: 12px; line-height: 1.2; text-align: center; mso-line-height-alt: 14px; margin: 0;"><span style="font-size: 16px; color: #000000;">Efficient Refrigerators</span></p>
        </div>
    </div>
    <!--[if mso]></td></tr></table><![endif]-->
    <!--[if mso]><table width="100%" cellpadding="0" cell[spacing="0" border="0"><tr><td style="padding-right: 10px; padding-left: 10px; padding-top: 10px; padding-bottom: 10px; font-family: Arial, sans-serif"><![endif]-->
    <div style="color:#555555;font-family:'Open Sans', Helvetica, Arial, sans-serif;line-height:1.2;padding-top:10px;padding-right:10px;padding-bottom:10px;padding-left:10px;">
        <div style="line-height: 1.2; font-family: 'Open Sans', Helvetica, Arial, sans-serif; font-size: 12px; color: #555555; mso-line-height-alt: 14px;">
            <p style="font-size: 12px; line-height: 1.2; text-align: center; mso-line-height-alt: 14px; margin: 0;"><span style="color: #808080; font-size: 12px;"><span style="font-size: 12px;">Choose efficient and save up to $240 a year in energy costs!</span></span></p>
        </div>
    </div>
    <!--[if mso]></td></tr></table><![endif]-->
    <!--[if mso]><table width="100%" cellpadding="0" border="0"><tr><td style="border-collapse: collapse; padding-right: 10px; padding-left: 10px; padding-top: 10px; padding-bottom: 10px; font-family: Arial, sans-serif"><![endif]-->
    <div style="border-collapse: collapse; color:#555555;font-family:'Open Sans', Helvetica, Arial, sans-serif;line-height:1.2;padding-top:10px;padding-right:10px;padding-bottom:10px;padding-left:10px;">
        <div style="font-family: 'Open Sans', Helvetica, Arial, sans-serif; font-size: 12px; line-height: 0; color: #555555; mso-line-height-alt: 14px;">
            <p style="font-size: 12px; line-height: 1.2; text-align: center; mso-line-height-alt: 14px; margin: 0;">Compare Deals and</p>
            <p style="font-size: 12px; line-height: 1.2; text-align: center; mso-line-height-alt: 14px; margin: 0;"><strong><span style="color: #000000; font-size: 12px;"><span style="font-size: 22px;">Save Big!</span></span></strong></p>
        </div>
    </div>
    <!--[if mso]></td></tr></table><![endif]-->
    <!--[if mso]><table width="100%" cellpadding="0" border="0" style="border-spacing: 0; border-collapse: collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;"><tr><td style="border-collapse: collapse; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px" align="center"><v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="" style="border-collapse: collapse; height:27.75pt; width:126pt; v-text-anchor:middle;" arcsize="60%" stroke="false" fillcolor="#307298"><w:anchorlock/><v:textbox inset="0,0,0,0"><center style="color:#ffffff; font-family:Arial, sans-serif; font-size:14px"><![endif]-->
    <div class="button-container" align="center" style="padding-top:10px;padding-right:10px;padding-bottom:10px;padding-left:10px;">
        <a href="" target="_blank" style="-webkit-text-size-adjust: none; text-decoration: none; display: inline-block; color: #ffffff; background-color: #307298; border-radius: 22px; -webkit-border-radius: 22px; -moz-border-radius: 22px; width: auto; width: auto; border-top: 1px solid #307298; border-right: 1px solid #307298; border-bottom: 1px solid #307298; border-left: 1px solid #307298; padding-top: 0px; padding-bottom: 5px; font-family: 'Open Sans', Helvetica, Arial, sans-serif; text-align: center; mso-border-alt: none; word-break: keep-all;"><span style="padding-left:20px;padding-right:20px;font-size:14px;display:inline-block;">
                <span style="font-size: 16px; line-height: 2; mso-line-height-alt: 32px;"><span style="font-size: 14px; line-height: 28px;"><strong><span style="line-height: 28px; font-size: 14px;">Compare Products</span></strong></span></span>
            </span></a>
    </div>
    <!--[if mso]></center></v:textbox></v:roundrect></td></tr></table><![endif]-->
    <!--[if (!mso)&(!IE)]><!-->
</div>                                      
<!--<![endif]-->

Smtplib gives partially initialized module error when trying to use it in python

$
0
0

I'm trying to make a python script that emails me stuff and i followed this tutorial about how to do it and i thought of making it work using SMTP_SSL()

import smtplib, ssl

port = 465
password = input("Type your password and press enter: ")

context = ssl.create_default_context()

sender_email = "me@gmail.com"
receiver_email = "some@gmail.com"
message = """\
Subject: Hi there

This message is sent from Python."""

with smtplib.SMTP_SSL("smtp.gmail.com", port, context=context) as server:
    server.login(receiver_email, password)
    server.sendmail(sender_email, receiver_email, message)

But it keeps giving me this error:

ImportError: cannot import name 'SMTP' from partially initialized module 'smtplib' (most likely due to a circular import)

Can anyone help me clarify what this error means and if there's a workaround for it. Any help appreciated.

Forward an email and append additional text without losing format of original message

$
0
0

I'm trying to forward an email that I received and append an additional message on top of it. The following code I wrote kinda does this, but I lose all the formatting of the original message. Is there any way to maintain the format of the original message and yet able to append additional test to the email?

MY CODE:

Sub xForward()
    myMessage = "You recently requested access to the table.   We are requiring all requests to complete a mandatory training session."& vbCr & vbCr & "Thank you, "& vbCr & "Ricky"

    Dim itmOld As MailItem, itmNew As MailItem

    Set itmOld = ActiveInspector.CurrentItem
    Set itmNew = itmOld.Forward

    itmNew.Body = myMessage & vbCr & vbCr & itmOld.Body
    itmNew.Subject = "Access Request"
    itmNew.Display

    Set itmOld = Nothing
    Set itmNew = Nothing
End Sub

If I don't update the body of itmNew, then I maintain the format of the original message. The moment I update itmNew.Body, then itmOld.Body is written in simple text and I lose all the formatting.


send mail Php Proplem [duplicate]

$
0
0

i am having an issue with PHP Mailer. It is sending a only Title of label without the content insert on each label the mail view as this :

Name :

Email:

Subject:

Message:

i do not have any information about php as a code , any help

Html code

<section id="contact-page"><div class="container"><div class="center"><h2>Drop Your Message</h2></div><div class="row contact-wrap"><div class="status alert alert-success" style="display: none"></div><form id="main-contact-form" class="contact-form" name="contact-form" method="post" action="sendemail.php"><div class="col-sm-5 col-sm-offset-1"><div class="form-group"><label>Name *</label><input type="text" name="name" class="form-control" required="required"></div><div class="form-group"><label>Email *</label><input type="email" name="email" class="form-control" required="required"></div><div class="form-group"><label>Phone</label><input type="number" class="form-control"></div><div class="form-group"><label>Company Name</label><input type="text" class="form-control"></div></div><div class="col-sm-5"><div class="form-group"><label>Subject *</label><input type="text" name="subject" class="form-control" required="required"></div><div class="form-group"><label>Message *</label><textarea name="message" id="message" required="required" class="form-control" rows="8"></textarea></div><div class="form-group"><button type="submit" name="submit" class="btnbtn-primary btn-lg" required="required">Submit Message</button></div></div></form></div></div></section>
php code 
<?php
header('Content-type: application/json');
$status = array(
    'type'=>'success',
    'message'=>'Thank you for contact us. As early as possible  we will contact you '
);

$name = @trim(stripslashes($_POST['name'])); 
$email = @trim(stripslashes($_POST['email'])); 
$subject = @trim(stripslashes($_POST['subject'])); 
$message = @trim(stripslashes($_POST['message'])); 

$email_from = $email;
$email_to = myemail@email.com';
$body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'Subject: ' . $subject . "\n\n" . 'Message: ' . $message;
$success = @mail($email_to, $subject, $body, 'From: <'.$email_from.'>');

echojson_encode($status); die;

Can I have a link automatically download a file in an email?

$
0
0

I have an email with a link to a video file stored on a cloud hosting service (backblaze)

I'm trying to make it so that when someone can clicks the link the file would start to download. Right now I have this:

<a href="https://f000.backblazeb2.com/file/Folder/video.mp4" download="video">Download Here</a>

That takes you to the video instead of downloading the file. I'd like to avoid that if possible and have the link prompt you to start downloading the file when you click on it.

Is this possible to do in an email when the file is stored on a server somewhere?

Thanks

Get an email from old temporary mailbox

$
0
0

I want to reregistrate my account to existing post but I need to get mail from old temporary post I haven't access. I want to make email server to get this but don't know how. Can anyone help me?

Using Mailjet to send email in PHP

$
0
0

I'm new to PHP and am doing a small project that's only on my localhost. I need it to actually send emails so I can verify that it's working. How the program work is there a form for the admin to fill out and send an email to a user in the database and the form is sent to the page that runs the API sending. I tried it with the example Mailjet had and it actually sent the email to my specified recipient, but I need to pass in the recipient, subject and body from the form and it won't send what am I doing wrong?

emailForm.php

<div id = "mail-create" class="col-6 border" style="display: none;">
          <h3 class="text-primary text-center">Send mail</h3>
          <form method="post" action="sendEmail.php">
            <input type="hidden" name="admin" value="1">
            <?php include('errors.php'); ?>
            <div class="form-group">
              <label for="firstname">Choose user</label>
              <select name="userEmail" id="userEmail">
                <?php foreach ($users as $user): ?>
                  <option value="<?=$user['email'] ?>"><?=$user['username'] ?></option>
                <?php endforeach; ?>
              </select>
            </div>
            <div class="form-group" action="action.php">
              <label for="subject">Subject</label>
              <input type="text" class="form-control" name="subject" id="subject">
            </div>
            <div class="form-group">
              <label for="message">Message</label><br>
              <textarea name="message" id="message" cols="50" rows="8" placeholder="Write message body here"></textarea>
            </div>
            <button type="submit" name="sendMail" value="send" class="btn btn-primary mb-2">Send mail</button>
          </form>
        </div>  

sendEmail.php

<?php
     require 'vendor/autoload.php';
     use \Mailjet\Resources;
     if(isset($_POST[‘sendMail’]){
    //passed in my actual api keys
       $mj = new \Mailjet\Client('MJ_APIKEY_PUBLIC','MJ_APIKEY_PRIVATE',true,['version' => 'v3.1']);
       $body = [
         'Messages' => [
           [
             'From' => [
               'Email' => "email@email.com",
               'Name' => "name"
             ],
             'To' => [
               [
                 'Email' => $_POST['userEmail'],
                 'Name' => "name"
               ]
             ],
             'Subject' => $_POST['userEmail'],
             'TextPart' => "My first Mailjet email",
             'HTMLPart' =>$_POST['message'],
             'CustomID' => "AppGettingStartedTest"
           ]
         ]
       ];
       $response = $mj->post(Resources::$Email, ['body' => $body]);
       $response->success() && var_dump($response->getData());
     }
     ?>

Python - Reply to an email

$
0
0

I want to reply to a specific message using python and smtp. I've already seen these posts:

Reply to email using python 3.4

How do I reply to an email using the Python imaplib and include the original message?

But unfortunately, it only sends a reply with this '--------- Forwarded message ----------' instead of replying in the normal way.

Please help!

The code is attached

def reply_to_msg(self, original_msg, reply_body):
    # fetch msg
    self.login_imap(host="imap.gmail.com", port=993, username='username@gmail.com', password="pass",
                  use_ssl=True)
    # Filter by subject because it is unique subject (uuid)
    # Get message ID
    mail_ids = self.receive_mail_ids(subject_filter=original_msg["Subject"])

    msg = MIMEMultipart("mixed")
    body = MIMEMultipart("alternative")

    text, _ = self.append_orig_text(reply_body, "", original_msg, True)

    body.attach(MIMEText(text, 'plain'))
    msg.attach(body)
    msg.attach(MIMEMessage(original_msg))

    msg["Message-ID"] = email.utils.make_msgid()
    msg['To'] = original_msg["From"]
    msg['Subject'] = "Re: " + original_msg["Subject"]
    msg['In-Reply-To'] = msg['References'] = mail_ids[-1]

    # send
    try:
        s = self.login_smtp(host="smtp.gmail.com", port=465, username='username@gmail.com', password="pass", use_ssl=True, use_auth=True)
        self.smtp.sendmail(original_msg['To'], [original_msg["From"]], msg.as_string())
    except Exception as error:
        raise EmailManagerError("sendmail: {}".format(error))

@staticmethod
def append_orig_text(text, html, orig, google=False):
    """
    Append each part of the orig message into 2 new variables
    (html and text) and return them. Also, remove any
    attachments. If google=True then the reply will be prefixed
    with ">". The last is not tested with html messages...
    """
    newhtml = ""
    newtext = ""

    for part in orig.walk():
        if (part.get('Content-Disposition')
                and part.get('Content-Disposition').startswith("attachment")):
            part.set_type("text/plain")
            part.set_payload("Attachment removed: %s (%s, %d bytes)"
                             % (part.get_filename(),
                                part.get_content_type(),
                                len(part.get_payload(decode=True))))
            del part["Content-Disposition"]
            del part["Content-Transfer-Encoding"]

        if part.get_content_type().startswith("text/plain"):
            newtext += "\n"
            newtext += part.get_payload(decode=False)
            if google:
                newtext = newtext.replace("\n", "\n> ")

        elif part.get_content_type().startswith("text/html"):
            newhtml += "\n"
            newhtml += part.get_payload(decode=True).decode("utf-8")
            if google:
                newhtml = newhtml.replace("\n", "\n> ")

    if newhtml == "":
        newhtml = newtext.replace('\n', '<br/>')

    return (text + '\n\n' + newtext, html + '<br/>' + newhtml)
Viewing all 29762 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>